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

Closed
xiaoxiangmoe opened this issue Dec 10, 2020 · 0 comments · Fixed by #41950
Closed

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

xiaoxiangmoe opened this issue Dec 10, 2020 · 0 comments · Fixed by #41950
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Quick Fixes Editor-provided fixes, often called code actions. Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Milestone

Comments

@xiaoxiangmoe
Copy link
Contributor

  • 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

@mjbvz mjbvz transferred this issue from microsoft/vscode Dec 10, 2020
@mjbvz mjbvz removed their assignment Dec 10, 2020
@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Dec 10, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 10, 2020
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Quick Fixes Editor-provided fixes, often called code actions. Help Wanted You can do this Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". and removed Experience Enhancement Noncontroversial enhancements labels Dec 11, 2020
@RyanCavanaugh RyanCavanaugh removed the Suggestion An idea for TypeScript label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Quick Fixes Editor-provided fixes, often called code actions. Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants