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

Add support for react-jsx in tsconfig.json compilerOptions -- upgrade to TS v4.1 #1073

Closed
pradella opened this issue Aug 26, 2021 · 1 comment
Labels
problem: removed issue template OP removed the issue template without good cause scope: dependencies Pull requests that update a dependency file solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue

Comments

@pradella
Copy link

pradella commented Aug 26, 2021

Hi everyone

Sharing my workaround for those who are struggling to fix compiler errors when using react-jsx in your tsconfig.json.

In my case, the error was: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686).

Solution: in tsconfig.json, change react-jsx to preserve, as replied in another issue:

// in tsconfig.json, change "react-jsx" to "preserve"
{
  "compilerOptions": {
    // ...
    "jsx": "preserve"
    // ...
  },
}

If possible in a near future, add support for react-jsx.

@agilgur5 agilgur5 changed the title Add support for react-jsx in tsconfig.json compilerOptions Add support for react-jsx in tsconfig.json compilerOptions -- upgrade to TS v4.1 Apr 12, 2022
@agilgur5 agilgur5 added solution: duplicate This issue or pull request already exists scope: dependencies Pull requests that update a dependency file solution: workaround available There is a workaround available for this issue problem: removed issue template OP removed the issue template without good cause labels Apr 12, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Apr 12, 2022

react-jsx is only supported by TS 4.1+, so this is due to TSDX using TS v3.

As such, this is duplicative of #926 , and the workarounds there using Yarn resolutions (or NPM overrides) to upgrade TS (and other deps) will work to enable the react-jsx config as well.

Sharing my workaround for those who are struggling to fix compiler errors when using react-jsx in your tsconfig.json.

Appreciate you sharing another workaround in the meantime though for other users who were stuck!

Repository owner locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
problem: removed issue template OP removed the issue template without good cause scope: dependencies Pull requests that update a dependency file solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue
Projects
None yet
Development

No branches or pull requests

2 participants