The Wayback Machine - https://web.archive.org/web/20210210080207/https://github.com/microsoft/TypeScript/issues/41920
Skip to content
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

Bug: react-jsxdev support for `add all missing imports` #41920

Open
xiaoxiangmoe opened this issue Dec 10, 2020 · 0 comments · May be fixed by #41950
Open

Bug: react-jsxdev support for `add all missing imports` #41920

xiaoxiangmoe opened this issue Dec 10, 2020 · 0 comments · May be fixed by #41950

Comments

@xiaoxiangmoe
Copy link

@xiaoxiangmoe xiaoxiangmoe commented Dec 10, 2020

  • 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)
image
6. type + .
image
7. Add all missing imports, then result:

import * as React from "react";

export default function Bar(){
  return <Foo></Foo>
}
  1. Move cursor to Foo, type + .
    image
  2. Add all missing imports, then result
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants