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
Bug
It isn't possible to declare a local variable with an dynamic imported class/type.
TypeScript Version:
2.7.1 (visual studio tools)
Code
//Module1.tsexportclassClass1{}//Module2.tsexportclassClass2{publicasyncTestMethod(){constmodule1=awaitimport("./Module1");varinstance=newmodule1.Class1();//works fine: Variable has type 'Class1'' (implicitly typed)varvariable1: module1.Class1;//doesn't work!!! Message: Cannot find namespace "module1"}}
Expected behavior:
The code compiles without errors. It's allowed to declare a variable with an dynamic imported type, because it works with implicitly typed local variables and non-dynamic imported module types, too.
Actual behavior:
For the variable1 declaration: Cannot find namespace "module1"
The text was updated successfully, but these errors were encountered:
STARSCrazy
changed the title
Dynamic Import Expression: Can't declare variables with imported types
Can't declare local variables with dynamic(!) imported types
Mar 2, 2018
You can just import { Class1 as Class1Type } from "module1"; at the top, and as long as you don't use that Class1Type as a value, it won't be in the emitted code. Although it would be nicer if we let you write import { type Class1 } from "module1"; and guaranteed that it wouldn't be used as a value.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Bug
It isn't possible to declare a local variable with an dynamic imported class/type.
TypeScript Version:
2.7.1 (visual studio tools)
Code
Expected behavior:
The code compiles without errors. It's allowed to declare a variable with an dynamic imported type, because it works with implicitly typed local variables and non-dynamic imported module types, too.
Actual behavior:
For the variable1 declaration: Cannot find namespace "module1"
The text was updated successfully, but these errors were encountered: