Skip to content

Conversation

@mondoreale
Copy link
Contributor

@mondoreale mondoreale commented Jan 20, 2026

Summary

Centralizes the tsyringe dependency injection setup by introducing a dedicated setupTsyringe.ts module that handles the reflect-metadata import. This eliminates the need for scattered import 'reflect-metadata' statements across source and test files, making the DI configuration more maintainable and ensuring consistent initialization.

Changes

  • Created packages/sdk/src/setupTsyringe.ts to centralize the reflect-metadata import
  • Updated core SDK entry points (StreamrClient.ts, Config.ts, ConfigTypes.ts, PersistenceManager.ts) to import the new setup module instead of reflect-metadata directly
  • Added setupTsyringe.ts to Jest's setupFilesAfterEnv configuration for automatic test initialization
  • Added setupTsyringe.ts import to karma-setup.js to fix the browser test build
  • Removed redundant import 'reflect-metadata' statements from 60+ test files

Limitations and future improvements

  • The setup module currently only imports reflect-metadata, but could be extended in the future to include other tsyringe configuration or polyfills if needed

@github-actions github-actions bot added the sdk label Jan 20, 2026
@mondoreale mondoreale requested a review from Copilot January 20, 2026 22:18
@mondoreale mondoreale marked this pull request as ready for review January 20, 2026 22:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the tsyringe dependency injection setup by consolidating all reflect-metadata imports into a single setupTsyringe.ts file. This improves maintainability by centralizing the reflect-metadata import, which is required for tsyringe decorators to work properly.

Changes:

  • Created a centralized setupTsyringe.ts file containing the reflect-metadata import
  • Updated main source files and test setup files to import from the centralized setup file
  • Removed direct reflect-metadata imports from all test files (50+ files)

Reviewed changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/sdk/src/setupTsyringe.ts New centralized file for tsyringe setup, imports reflect-metadata
packages/sdk/src/StreamrClient.ts Updated to import from setupTsyringe instead of reflect-metadata directly
packages/sdk/src/PersistenceManager.ts Updated to import from setupTsyringe (appropriate, uses @Scoped decorator)
packages/sdk/src/ConfigTypes.ts Updated to import from setupTsyringe (unnecessary but harmless)
packages/sdk/src/Config.ts Updated to import from setupTsyringe (unnecessary but harmless)
packages/sdk/jest.config.ts Added setupTsyringe to setupFilesAfterEnv array to ensure it loads before tests
packages/sdk/jest.setup.ts Removed reflect-metadata import (now loaded via jest.config.ts)
packages/sdk/karma-setup.js Added setupTsyringe import for browser tests
All test files (50+ files) Removed direct reflect-metadata imports (now loaded via test setup)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mondoreale mondoreale merged commit e2ef301 into main Jan 20, 2026
42 of 43 checks passed
@mondoreale mondoreale deleted the dry-tsyringe-setup branch January 20, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants