-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Organize imports removes react imports in js projects that don't configure "jsx" #23287
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
Comments
I believe we already have heuristics for this. Sounds like you're just asking us to drop the check for the compiler option? |
Confirmed that the import is correctly retained if |
@mhegazy The perf cost of removing the check looks negligible but I don't know enough about JSX to understand the correctness implications. |
I assume the worst case is that we might never remove such imports, which seems acceptable. |
I think removing the check for the compiler option is the safer choice. we have a problem that it will be tagged as unused and now shown as grey.. but i guess that is a different bug. |
It is rather annoying that we can gray it out accurately but not organize/remove it accurately. |
@mhegazy As I recall, we did it that way because we didn't want to trigger a full bind for the refactoring? |
...based on feedback from VS Code users. Fixes microsoft#23287
@mhegazy I've created a PR to have organizeImports stop deleting it. What do you want to do about not removing grayed out imports? File a Future bug? |
Yes please. |
As we discussed offline, we can improve the heuristic now so there's no reason to file a separate bug. |
From microsoft/vscode#47287
TypeScript Version: 2.9.0-dev.20180409
Search Terms:
Code
For a simple js project that does not configure
"jsx
:jsconfig.json
:index.js
:Problem:
Typescript (correctly from its perspective) removes the
React
import asReact
is not referenced anywhere. However this is very confusing for users.Proposal:
Some ideas:
Special case
React
imports for files that use jsx even when you don't have"jsx"
configuredDefault
"jsx"
on for jsconfig projects (the jsconfigs that vscode generates for users already do this). Allow the config to turn if off it a user really needs toShow an editor suggestion on jsx in js files that are part of a jsconfig project that does not configure
"jsx"
The text was updated successfully, but these errors were encountered: