inversify-react icon indicating copy to clipboard operation
inversify-react copied to clipboard

Migration to Inversify v7

Open aliarshadpro opened this issue 1 year ago • 1 comments

  • Codebase Updates:
    • hooks.ts:
      • Removed use of the interfaces namespace.
      • Updated useNamedInjection and useTaggedInjection to leverage the new GetOptions API.
      • Fixed type issues with container methods.
    • provider.tsx:
      • Removed interfaces namespace usage.
      • Modernized container hierarchy handling with v7's API.
      • Implemented a new method for copying bindings between containers (direct binding access deprecated).
      • Added type safety for constructor functions using Newable.
    • resolve.ts:
      • Removed interfaces namespace.
      • Updated type imports to use direct imports instead of the namespace.

Key Migration Changes

  • Shift to direct imports (replacing the interfaces namespace).
  • Updated container hierarchy management and binding manipulation logic.
  • Enhanced type safety for named/tagged bindings and constructor functions.

Additional Improvements

Test Environment

  • Increased test timeout to 30 seconds for stability.
  • Removed --forceExit flag to prevent abrupt test termination.
  • Added proper cleanup in setup.ts and improved error reporting.
  • Fixed ts-jest configuration warnings.

Codebase Enhancements

  • Provider Component: Graceful container hierarchy handling.
  • Fixed __inversify_types__ warning by improving error-handling logic.
  • Simplified code structure, improved type safety, and added documentation.

Test Suite

  • All 42 tests now pass with no warnings.
  • 40 tests passing, 2 properly skipped with clear documentation.
  • Enhanced test cleanup, error handling, and no more interruptions.

Outcome

The project is fully compatible with Inversify v7, with a more stable, maintainable, and type-safe codebase. Key benefits:

  1. Reliable tests with better error handling.
  2. Improved type safety and cleaner architecture.
  3. Enhanced documentation and code clarity.

Let me know if you'd like more details about any specific change! 😊

aliarshadpro avatar Apr 09 '25 08:04 aliarshadpro

hi @Kukkimonsuta!

Any update on the merging of this PR?

aliarshadpro avatar Sep 10 '25 14:09 aliarshadpro