-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptDomain: API: TransformsRelates to the public transform APIRelates to the public transform API
Milestone
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
matt-gadd, HoldYourWaffle, vtabary, ybeauchamph, devversion and 1 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptDomain: API: TransformsRelates to the public transform APIRelates to the public transform API