You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Typescript 3.8, Typescript has supported type-only imports and exports. This feature is incompatible with constructor dependency injection.
Current behavior
If you do a type-only import, you get an error like
Error: Nest can't resolve dependencies of the AppController (?, Function, Function, Function, UserSessionRepository). Please make sure that the argument Function at index [0] is available in the RootTestModule context.
The dependency injection runs during the use of node, not of tsc. This means that what's happening during the build phase is simply just transpiling Typescript into JavaScript, during this time, typed imports are checked for proper types, and then become {} just like interfaces. This isn't something that Nest will be able to get around, but rather something that should be taken into account during development. If you want to use class interfaces, or injection tokens with custom providers, that's something that can be managed, but Nest's DI system cannot get around what Typescript does with import type.
See typescript-eslint/typescript-eslint#2559 for discussion there
Bug Report
Since Typescript 3.8, Typescript has supported type-only imports and exports. This feature is incompatible with constructor dependency injection.
Current behavior
If you do a type-only import, you get an error like
Input Code
Expected behavior
The dependencies should be injected as per usual.
Possible Solution
nest.js should be able to resolve type-only imports. Possibly by doing its injection earlier in the typescript build phase
Environment
The text was updated successfully, but these errors were encountered: