Skip to content

Intellisense/import Code Actions don't work with React JSX Transform unless React is in scope #50192

@nhuesmann

Description

@nhuesmann

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

  • VS Code Version: 1.70.0
  • OS Version: Mac OS 12.4

Steps to Reproduce:

I created a reproducible demo using npx create-expo-app -t expo-template-blank-typescript. The only change I made was adding the basic React component and adding it to App.tsx without the import.

  1. Clone the reproducible demo I created https://github.com/nhuesmann/vscode-react-jsx-transform-issue
  2. cd <my-repo-you-cloned>
  3. Install dependencies: npm i or yarn
  4. code --disable-extensions .
  5. Open App.tsx
  6. Notice the error on line 8 with the <Test /> component
  7. Click on the component and use cmd + . to bring up Code Actions
  8. Observe VS Code's suggestion: import 'React' from "react"
  9. Accept the suggestion
  10. Once again use cmd + . (while clicked on <Test />) to bring up Code Actions
  11. Observe VS Code's suggestion of Add import from "./Test"

The second suggestion should be suggested initially, since React's JSX Transform does not require React to be in scope. VS Code will not do JSX import suggestions unless React is in scope.

Related issue: #41762
Temporary workaround: #41762 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions