Typescript: Import incorrectly removed during transpilation

Created on 1 Jun 2018  路  5Comments  路  Source: microsoft/TypeScript


Currently I'm having an issue where I've imported a variable, and the import is being removed during transpilation. The reference still remains, but the code breaks at runtime because the import is missing.


TypeScript Version: 3.0.0-dev.201xxxxx, 2.9.1, 2.9.0-dev.20180406

I was able to pinpoint the issue to 2.9.0-dev.20180406 but I am having issues creating a small repro case.


Search Terms:
Import missing reference

Code
I'm having trouble creating a contained repro, but the issue is currently occurring when an imported reference is used only in super clause of a constructor.

Expected behavior:
The import for an imported reference should exist after transpilation.

Actual behavior:
The import is removed during transpillation.

Playground Link:

Related Issues:

Bug Fixed

Most helpful comment

I was able to reproduce this in http://www.typescriptlang.org/play/#src=import%20X%20from%20'file'%3B%0Aimport%20Z%20from%20'other_file'%3B%0A%0Aclass%20Y%20extends%20Z%20%7B%0A%20%20constructor()%20%7B%0A%20%20%20%20super(X)%3B%0A%20%20%7D%0A%7D

Note how file_1 is referenced but never declared.

All 5 comments

I was able to reproduce this in http://www.typescriptlang.org/play/#src=import%20X%20from%20'file'%3B%0Aimport%20Z%20from%20'other_file'%3B%0A%0Aclass%20Y%20extends%20Z%20%7B%0A%20%20constructor()%20%7B%0A%20%20%20%20super(X)%3B%0A%20%20%7D%0A%7D

Note how file_1 is referenced but never declared.

@weswigham please take a look at this one for 2.9.2

Is the fix in the latest version? I still have the issue as shown here: https://github.com/TypeStrong/ts-loader/issues/787#issuecomment-395644414. In my case, there are multiple arguments when calling the super ().

The latest official release? Not yet - were planning to cut a release next week.

My test is against version "3.0.0-dev.20180607".

Was this page helpful?
0 / 5 - 0 ratings