question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript 4.1: Cannot assign to read only property 'jsx' of object

See original GitHub issue

Describe 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

Screenshot 2020-11-20 at 02 39 57

Reproducible demo

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:40
  • Comments:18

github_iconTop GitHub Comments

20reactions
Hillshumcommented, Nov 20, 2020

Also reproducible in a brand-new project created with --template typescript

https://github.com/Hillshum/jsx-readonly

15reactions
fedellencommented, Nov 20, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found