Skip to content

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

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)
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

Activity

  1. removed their assignment
    on Dec 10, 2020
  2. added
    BugA bug in TypeScript
    Domain: JSX/TSXRelates to the JSX parser and emitter
    Domain: LS: Quick FixesEditor-provided fixes, often called code actions.
    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
    and removed on Dec 11, 2020
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions