Typescript 4.1: Cannot assign to read only property 'jsx' of object
See original GitHub issueDescribe the bug
Upgrading to typescript 4.1 which apparently introduced React 17 JSX Factories causes the error Cannot assign to read only property 'jsx' of object
when using .tsx
file.
Did you try recovering your dependencies?
Yes
Environment
Environment Info:
current version of create-react-app: 4.0.0
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Binaries:
Node: 15.0.1 - ~/.nvm/versions/node/v15.0.1/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 7.0.3 - ~/.nvm/versions/node/v15.0.1/bin/npm
Browsers:
Chrome: 87.0.4280.67
Edge: Not Found
Firefox: 82.0.3
Safari: 14.0
npmPackages:
react: ^17.0.1 => 17.0.1 (16.14.0)
react-dom: ^17.0.1 => 17.0.1 (16.14.0)
react-scripts: ^4.0.0 => 4.0.0
Steps to reproduce
Upgrade to typescript 4.1.2 using tsx files causes the error
Actual behavior
Reproducible demo
Issue Analytics
- State:
- Created 3 years ago
- Reactions:40
- Comments:18
Top Results From Across the Web
TypeError: Cannot assign to read only property 'jsx' of object ...
Workaround for those who want to use TypeScript 4.1 and create-react-app 4.0.0: set the environment variable DISABLE_NEW_JSX_TRANSFORM to true ...
Read more >TypeError: Cannot assign to read only property 'jsx' of object ...
TypeError : Cannot assign to read only property 'jsx' of object '#<Object>'. While creating a new react project with typescript by running the...
Read more >Error when updating create-react-app to 4.0 with typescript ...
It just skips running the buggy code below which will assign the suggested value to the typescript compiler option if not provided.
Read more >Documentation - Object Types - TypeScript
Cannot assign to 'resident' because it is a read-only property.2540Cannot assign to 'resident' because it is a read-only property. name : "Victor the...
Read more >typescript cannot assign read only propertie - You.com
Upgrading to typescript 4.1 which apparently introduced React 17 JSX Factories causes the error Cannot assign to read only property 'jsx' of object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also reproducible in a brand-new project created with
--template typescript
https://github.com/Hillshum/jsx-readonly
also stumbled across this issue –
after rolling back typescript and changing jsx to react in tsconfig I was able to get ‘npm start’ to work.
npm install typescript@4.0.5
tsconfig.json:
"jsx": "react"
probably not a long lasting workaround though