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

Typescript react: unable to auto import react components unless React is in scope #41958

Closed
ialexi-bl opened this issue Dec 14, 2020 · 3 comments
Assignees
Labels
Duplicate An existing issue was already created

Comments

@ialexi-bl
Copy link

ialexi-bl commented Dec 14, 2020

TS Template added by @mjbvz

TypeScript Version: 4.1.2

Search Terms

  • jsx
  • react

With React version 17 it's no longer necessary to import React in order to use JSX. However VS code refuses to automatically import a component that is not in scope and used in JSX. It only shows an option import default 'React' from module 'react'. If I do this, it then shows an option to import the missing component.

This only seems to happen in typescript projects, in javascript there is no quick fixes related to import at all, but I've never worked with javascript projects I don't know if this is supposed to happen.

  • VSCode Version: 1.53.0-insider
  • OS Version: Windows 10 2004

Steps to Reproduce:

  1. Create an empty react app using typescript, I tested with npx create-react-app test --template typescript
  2. Create a Test component in test.jsx
  3. Use Test component in App.jsx without importing either Test or React
  4. Test component will have red squiggles, open quick fix on it and see that there is no option
    to import Test, only to open React
  5. Now import React and see that importing Test option has appeared

Repo: https://github.com/ialexi-bl/react-vscode-issue-reproduction
Open App.tsx and try to quick fix missing Test import

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

@vscodebot
Copy link

vscodebot bot commented Dec 14, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@mjbvz mjbvz transferred this issue from microsoft/vscode Dec 14, 2020
@mjbvz
Copy link
Contributor

mjbvz commented Dec 14, 2020

Potentially related to #41920

@RyanCavanaugh
Copy link
Member

Same root cause as #41920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants