Closed
Description
- VSCode Version: 1.51.1
- OS Version: Darwin x64 20.1.0
Steps to Reproduce:
1.mkdir vscode-react-import && cd vscode-react-import
2.yarn add react @types/react typescript
3. modify files as bellow
tsconfig.json
{
"compilerOptions": {
"module": "es2020",
"moduleResolution": "node",
"jsx": "react-jsxdev"
}
}
.vscode/settings.json
{
"typescript.tsdk": "node_modules/typescript/lib"
}
foo.tsx
export default function Foo(){
return <></>
}
bar.tsx
export default function Bar(){
return <Foo></Foo>
}
4.Select TypeScript version, Use workspace version 4.1.2
5. Move cursor to Foo, see error Cannot find name 'Foo'.ts(2304)
6. type ⌘
+ .
7. Add all missing imports, then result:
import * as React from "react";
export default function Bar(){
return <Foo></Foo>
}
import * as React from "react";
import Foo from "./foo";
export default function Bar(){
return <Foo></Foo>
}
We should not add import * as React from "react";
when tsconfig has "jsx": "react-jsxdev"
or "jsx": "react-jsx"
Does this issue occur when all extensions are disabled?: Yes