Closed
Description
TypeScript Version: 2.9.0-dev.20180409
Search Terms:
- organize imports
- jsx
Code
For a simple js project that does not configure "jsx
:
jsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "es2016",
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
index.js
:
import * as React from 'react'
const Button = () => <button />
- Run organize imports
Problem:
Typescript (correctly from its perspective) removes the React
import as React
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"
configured -
Default
"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 to -
Show an editor suggestion on jsx in js files that are part of a jsconfig project that does not configure
"jsx"