nicojs / typed-inject

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

note strictFunctionTypes is required; add an interface test #31

Closed kyle-johnson closed 2 years ago

kyle-johnson commented 3 years ago

Thanks for creating this library! I've tried multiple IoC containers and this is the first that is actually type-safe at compile time. 👍

I ran into a problem integrating this into my codebase: empty classes were able to satisfy type checking for provideClass(), even if the class didn't fulfill an interface.

I added a test to type-inject, testResources/tokens-of-interfaces.ts, which showed no issue with type-inject (included in this PR; it may be redundant with other tests?).

It appears strictFunctionTypes must be set to true for empty classes to be properly checked (typed-inject uses "strict": true). A note is added to the README.md to for this requirement.

nicojs commented 2 years ago

Thanks for the kind words and the PR @kyle-johnson 🤟