nicojs / typed-inject

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

Support TS 3.8 with full type safety #20

Closed nicojs closed 2 years ago

nicojs commented 4 years ago

Due to https://github.com/microsoft/TypeScript/issues/37400 it is allowed to assign a parent injector to a child injector.

const fooInjector: Injector<{foo: string}> = rootInjector;
// ERROR in TS <3.8
// OK According to TS >= 3.8

fooInjector.resolve('foo'); // Breaks at runtime!!

I'll close this issue once it's fixed at TS side.