jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.2k stars 505 forks source link

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

Closed pradella closed 2 years ago

pradella commented 2 years ago

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 commented 2 years ago

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!