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

Unable to use typescript 4 with react-scripts 4 and npm 7.0.5 #9892

Closed
MichaelHindley opened this issue Oct 24, 2020 · 8 comments · Fixed by #9964
Closed

Unable to use typescript 4 with react-scripts 4 and npm 7.0.5 #9892

MichaelHindley opened this issue Oct 24, 2020 · 8 comments · Fixed by #9964

Comments

@MichaelHindley
Copy link

MichaelHindley commented Oct 24, 2020

One of the release notes for 4.0.0 is support for typescript v4,
so as a user I'd expect to be able to use typescript 4 with react-scripts 4.0.0.

Case:
package.json with react-scripts 4.0.0 and typescript 4.0.3 with npm on latest (7.0.5)

Result:
image

Expected:
No error

Fallback: Use ts 3.9.7

@malcolm-kee
Copy link

malcolm-kee commented Oct 25, 2020

Have you tried delete your yarn.lock/package-lock.json and install again?

I just upgraded one of my projects and typescript 4 support is fine.

@MichaelHindley
Copy link
Author

@malcolm-kee very much so. Are you also using npm v7.0.5?

image

@malcolm-kee
Copy link

@MichaelHindley opps, I am using npm 6. Sorry I miss out that 😅

@mafull
Copy link

mafull commented Oct 27, 2020

I've got the same issue - npm v7.0.3, react-scripts v4.0.0

@ouifi
Copy link

ouifi commented Oct 27, 2020

I am having this issue as well, but with TS 3.9.7, and npm 6.14.7.

After running npm install react-scripts@latest

$ npm start

> [email protected] start D:\dev\js\project
> react-scripts start

D:\dev\js\project\node_modules\react-scripts\scripts\utils\verifyTypeScriptSetup.js:231
        appTsConfig.compilerOptions[option] = suggested;
                                            ^

TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible
    at verifyTypeScriptSetup (D:\dev\js\project\node_modules\react-scripts\scripts\utils\verifyTypeScriptSetup.js:231:45)
    at Object.<anonymous> (D:\dev\js\project\node_modules\react-scripts\scripts\start.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:1251:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
    at Module.load (internal/modules/cjs/loader.js:1100:32)
    at Function.Module._load (internal/modules/cjs/loader.js:962:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

@ggascoigne
Copy link

Add "noFallthroughCasesInSwitch": true, to your tsconfig.json.

@riceboyler
Copy link

Can I suggest that this little tidbit be added to the Release Notes? (I know that's not on you @ggascoigne)

@ggascoigne
Copy link

sorry I would have written a longer reply at the time but I was on the phone chatting to someone with this exactly problem at the time :)

I actually found this snippet in another variation of this bug elsewhere in this repo. I think that the cause is something to do with the assumptions about what the expected config is have changed and there's no automated migration.

But, yes, adding this to the release notes and or upgrading the error handling with a more useful error message would be neat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants