Skip to content

'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. #60132

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

Closed
danikane opened this issue Oct 3, 2024 · 21 comments · Fixed by #60122
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@danikane
Copy link

danikane commented Oct 3, 2024

Hi,
JavaScript and TypeScript Nightly version 5.7.20240928 and subsequent versions report the above message.

Next.js 13 or 14, pages router
Windows 10 with WSL2
VSCode 1.93.1

This is a React Fragment and there are several workarounds, but none of them are desired:

  • import React obviously
  • change "jsx": "preserve" -> to "jsx": "react-jsx" in tsconfig.json in which case Next will slap you
    image
  • change to div or whatever :)

image

image
image

On a side note ESLint doesn't pick it up when linting, but then again it's misleading.
Thanks!

@mjbvz mjbvz transferred this issue from microsoft/vscode-typescript-next Oct 3, 2024
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Oct 3, 2024
@iisaduan
Copy link
Member

iisaduan commented Oct 3, 2024

@danikane does this only happen when the config is set to jsx: preserve? Can you install and try #60122 (comment)?

@danikane
Copy link
Author

danikane commented Oct 3, 2024

Yes, exactly. That's what Next.js automatically sets anyway.
I can try tomorrow and get back with the results, if that's ok with you.
Thanks!

@danikane
Copy link
Author

danikane commented Oct 3, 2024

By the way should I leave the latest nightly installed?

@iisaduan
Copy link
Member

iisaduan commented Oct 3, 2024

If you npm install the dev version I linked, it will remove the nightly version and install the dev version in its place. You can either reference it in your dev dependencies and then run npm install, or use npm install typescript@npm:@typescript-deploys/[email protected] (regardless of what is in your dependencies) to try it out.

@iisaduan
Copy link
Member

iisaduan commented Oct 4, 2024

@danikane I've made changes to that PR that shouldn't affect typechecking, but I've packed a new version just in case: #60122 (comment)
"typescript": "npm:@typescript-deploys/[email protected]"

@danikane
Copy link
Author

danikane commented Oct 4, 2024

@iisaduan Thank you, I confirm the error is no longer reported!

image

image

@iisaduan
Copy link
Member

iisaduan commented Oct 4, 2024

Great, thank you for confirming!

@imranbarbhuiya
Copy link

Seems like it's happening in stable release too using "jsx": "react-native",

@imranbarbhuiya
Copy link

Hi @iisaduan, sorry for the ping but should i create a new issue for it or this can fixed from this issue only?

@ChromeQ
Copy link

ChromeQ commented Nov 25, 2024

Seems like it's happening in stable release too using "jsx": "react-native",

Same thing here

@iisaduan
Copy link
Member

@imranbarbhuiya Either is fine, thanks for the ping! I'm looking into it.

@ChromeQ
Copy link

ChromeQ commented Dec 27, 2024

Another nudge as it's been a while, any progress looking into this for "jsx": "react-native"?

@iisaduan
Copy link
Member

@ChromeQ can you try out nightly, and see if the error still occurs?

For react-native, it should be tracked by the new issue and fixed by #60615 . We haven't had an official release (patch) since 5.7, so there's no stable version with the fix yet

@techgerm
Copy link

Is there an update on when this fix will be included in 5.7 as a patch?

@jakebailey
Copy link
Member

The PR which closed this issue was in 5.7's RC; are you talking about some other fix? #60615 mentioned above was in 5.7.3. I don't think there is anything in this thread that is unreleased in some stable version.

@techgerm
Copy link

@jakebailey my apologies, to my knowledge there doesn't seem to be an easy way for me to check in which release a certain fix was included so I tried double checking the 5.7 branch and clearly made a mistake then.

Regardless, I was double checking whether the fix was included in 5.7.3 because after updating to this version, it still does not resolve the problem for us and we're also using `"jsx": "react-native".

@ChromeQ can you install 5.7.3 and see if this fixes the problem for you?

@jakebailey
Copy link
Member

jakebailey commented Jan 27, 2025

It's possible this is an extension I have, but:

Image

Image

(Note the tags)

@techgerm
Copy link

@jakebailey sorry could you share specifically which extension you have?

@jakebailey
Copy link
Member

I believe this is something Refined GitHub does.

@ChromeQ
Copy link

ChromeQ commented Jan 28, 2025

@techgerm
@ChromeQ can you install 5.7.3 and see if this fixes the problem for you?

I've upgraded to latest (and tried downgrading to reproduce the error but cannot anymore) and I can confirm it is working perfectly for me using "jsx": "react-native" 🎉 Thank you.

@techgerm
Copy link

Actually I can confirm that's working for us as well - I didn't realize that my VSCode was using 5.7.2 as appose to my workspace TS version. Thanks @jakebailey! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants