nicojs / typed-inject

Type safe dependency injection for TypeScript
Apache License 2.0
439 stars 23 forks source link

feat(decorator): add decorator functionality #6

Closed nicojs closed 5 years ago

nicojs commented 5 years ago

Add the ability to override a token. Previously this resulted in a stack overflow error when resolving the token.

     const answerProvider = rootInjector
        .provideValue('answer', 42)
        .provideValue('answer', '42');
      expect(answerProvider.resolve('answer')).eq('42');
      expect(typeof answerProvider.resolve('answer')).eq('string');

With this functionality in place, it is now also possible to add decorators to existing dependencies. See readme for more info.