File import ignored if the file containing the import statement doesn't explicitely reference a class deifined in the file #5098
Labels
Question
An issue which isn't directly actionable in code
Class
MyClass
is defined inmy-class.ts
. The class is decorated with a custom decorator. The result of the decorator is some logic that will eventually causeMyClass
to be instantiated.Another file,
other-file.ts
, importsmy-class.ts
with:other-file.ts
has no explicit reference toMyClass
, as it will automatically be instantiated and used as needed as a result of its decorator.This works fine, until I try to import an interface, exported by
my-class.ts
If I change the import within
other-file.ts
to:I can now reference
ISomeInterface
withinother-file.ts
, but now the contents ofmy-class.ts
is never actually compiled.I suspect this is due to some optimization by the Typescript compiler. In general it would make sense that if nothing but interfaces were referenced from a class, there's no reason to generate javascript for it; however, the use of decorators makes that assumption erroneous.
The text was updated successfully, but these errors were encountered: