Open
Description
Description of the bug:
When using a before transform that makes an import unused, the import will not be removed by TypeScript.
So if I have:
import { unused } from 'unused-module';
import { something } from 'some-module';
const value = something;
And replace const value = something
with
import { somethingElse } from 'some-other-module';
const value = somethingElse;
The import { unused } from 'unused-module';
statement will be removed, but import { something } from 'some-module';
will remain:
import { something } from 'some-module';
import { somethingElse } from 'some-other-module';
const value = somethingElse;
TypeScript Version: 2.4.2
Code
import { unused } from 'unused-module';
import { something } from 'some-module';
const value = something;
Reproduction of this bug requires using the transforms API.
I have prepared a repository with a simple reproduction that runs this file: https://github.com/filipesilva/ts-transform-import-bug/blob/master/test.ts
git clone https://github.com/filipesilva/ts-transform-import-bug
cd ts-transform-decorator-bug
npm install
npm test
Expected behavior:
All unused imports are removed.
import { somethingElse } from 'some-other-module';
const value = somethingElse;
Actual behavior:
Only imports there were unused before the transformed are removed.
import { something } from 'some-module';
import { somethingElse } from 'some-other-module';
const value = somethingElse;
/cc @rbuckton