-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterRelates to the JSX parser and emitterDomain: LS: Organize ImportsIssues with the organize imports featureIssues with the organize imports featureDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.FixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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
Reactimports 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"
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterRelates to the JSX parser and emitterDomain: LS: Organize ImportsIssues with the organize imports featureIssues with the organize imports featureDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.FixedA PR has been merged for this issueA PR has been merged for this issue