Skip to content

Preserve jsx imports even when the compiler option is not set #24311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2018

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented May 22, 2018

...based on feedback from VS Code users.

Fixes #23287

@amcasey amcasey requested a review from mhegazy May 22, 2018 01:11
@@ -92,7 +92,7 @@ namespace ts.OrganizeImports {
function removeUnusedImports(oldImports: ReadonlyArray<ImportDeclaration>, sourceFile: SourceFile, program: Program) {
const typeChecker = program.getTypeChecker();
const jsxNamespace = typeChecker.getJsxNamespace();
const jsxContext = sourceFile.languageVariant === LanguageVariant.JSX && program.getCompilerOptions().jsx;
const jsxContext = sourceFile.languageVariant === LanguageVariant.JSX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wounder if a better check here is sourceFile.transformFlags & TransformFlags.ContainsJsx !== 0.. this way we only keep it if we know at least one JSX element exist..

@amcasey amcasey changed the title Preserver jsx imports even when the compiler option is not set Preserve jsx imports even when the compiler option is not set May 22, 2018
@amcasey amcasey merged commit bedc110 into microsoft:master May 22, 2018
@amcasey amcasey deleted the GH23287 branch May 22, 2018 18:23
@mhegazy mhegazy mentioned this pull request May 22, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants