Closed davakos closed 3 years ago
Thanks for pointing it out, I'm sure that will help future users, probably the issue will be fixed on his side asap
Update: This appears to be fixed in create-react-app/react-scripts 4.0.1.
I have not tested exhaustively, but this worked in my testing:
setupI18n
option missing
npm run extract
properly extracts new strings into a message catalog filenpm run compile
properly compiles new strings into a message fileEnvironment:
I tested this both in an existing app that I upgraded to React 17 + TypeScript 4 and also in a test app I just bootstrapped using latest 4.0.1 version of create-react-app and following LinguiJS documentation here: https://lingui.js.org/tutorials/setup-cra.html
One thing I'd like to note from the docs on using LinguiJS with TypeScript documentation: https://lingui.js.org/guides/typescript.html
I am still setting compilerOptions
=> "target": "es2016"
in tsconfig.json
, but when I set "jsx": "preserve"
this setting is overwritten with "react-jsx"
whenever you call react-scripts (such as by running npm start
). You will also briefly see the following console message as the dev server starts:
The following changes are being made to your tsconfig.json file:
- compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17)
There does not appear to be any way to prevent or override this behavior, but at the same time, I appear to be able to still utilize all LinguiJS functionality without setting "jsx": "preserve"
. I have not tested this exhaustively, but perhaps if LinguiJS maintainers have an opportunity to ensure this does not cause any breakages or unintended side-effects, the LinguiJS/TypeScript documentation noted above could be updated to indicate that this option is no longer required if using TS4+React 17+CRA 4.0.1.
Best regards,
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug Informational: This is not a LinguiJS bug, but does impact the ability to run Lingui when using Create React App 4 with TypeScript. It appears that CRA4 currently fails if you set
"jsx": "preserve"
in yourtsconfig.json
file, which a Lingui requirement for preserving JSX and tagged template literals: https://lingui.js.org/guides/typescript.htmlIn create-react-app project refer to the following issues:
To Reproduce
npx create-react-app cra4 --template redux-typescript
Then modifytsconfig.json
and change:run dev server with:
npm start
Results:
Expected behavior Setting
jsx:preserve
fails to start a run server. Settingjsx:react
(the default) starts a run server but Lingui is unable to extract message catalogs.Additional context
3.0.3
7.12.3
4.0.0
4.0.5