Skip to content

JSX import fixes do not support new React JSX Transform (without react import) #41762

Closed
@cduff

Description

@cduff

TS Template added by @mjbvz

TypeScript Version: 4.1.2

Search Terms

  • react
  • jsx

  • VSCode Version: 1.51.1
  • OS Version: Windows 10 Pro

React 17 introduced a new JSX transform which does not require react to be imported in every file. Support for this was added in TypeScript 4.1. However vscode is still suggesting/requiring the react import before other JSX import fixes are suggested.

Steps to Reproduce:

  1. npx create-react-app my-app --template typescript
  2. cd my-app
  3. code --disable-extensions .
  4. Tell vscode to use the Workspace TypeScript version (4.1.2).
  5. Add a src/Test.tsx file with content export default function Test() { return <App />; }. It should show a problem Cannot find name 'App'..
  6. Click to show fixes. It unnecessarily suggests/requires import default 'React' from module "react" before it will suggest the desired import default 'App' from module "./App".

In short, you can't get help with JSX imports without littering your files with unnecessary react imports.

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions