Skip to content

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

Closed
@MichaelHindley

Description

@MichaelHindley

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

Activity

malcolm-kee

malcolm-kee commented on Oct 25, 2020

@malcolm-kee

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

MichaelHindley commented on Oct 25, 2020

@MichaelHindley
Author

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

image

malcolm-kee

malcolm-kee commented on Oct 25, 2020

@malcolm-kee

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

mafull

mafull commented on Oct 27, 2020

@mafull

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

ouifi

ouifi commented on Oct 27, 2020

@ouifi

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

> project@0.1.0 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

ggascoigne commented on Oct 28, 2020

@ggascoigne

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

riceboyler

riceboyler commented on Oct 28, 2020

@riceboyler

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

ggascoigne

ggascoigne commented on Oct 28, 2020

@ggascoigne

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ggascoigne@MichaelHindley@riceboyler@malcolm-kee@mafull

      Issue actions

        Unable to use typescript 4 with react-scripts 4 and npm 7.0.5 · Issue #9892 · facebook/create-react-app