-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
4.0 alpha - TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible #9429
Comments
Didn't read too much in to this but this seems to be working for me. Not sure why Immer is being used in this case where the readTsConfig object doesn't seem to be changed at all? Guessing there's some need for a shallow or deep copy of verifyTypeScriptSetup.js Before: let result;
parsedTsConfig = immer(readTsConfig, config => {
result = ts.parseJsonConfigFileContent(
config,
ts.sys,
path.dirname(paths.appTsConfig)
);
}); After: parsedTsConfig = {...readTsConfig};
const result = ts.parseJsonConfigFileContent(
parsedTsConfig,
ts.sys,
path.dirname(paths.appTsConfig)
);
|
@jamsch I can confirm that the above change fixed it for me. 🙂 |
This was an issue for me on the first few days after the Alpha-77 release and I had to use the fix from comments above to make it work.. but then it suddenly started working and I have no idea what fixed it. Anyway, you might want to check it again and close the issue if it's no longer an issue :) |
I was able to sidestep this error by adding |
I am getting a similar error, but for a different property... Cannot add property paths, object is not extensible I know that |
I'm also seeing the above (noFallthroughCasesInSwitch object is not extensible) error, even after running npm ci |
Same issue here and fixed with the |
Note: this also happens if you have configured |
This fixed the issue, but vscode cannot recognise the paths, it is a deal breaker for me |
Maybe there should be a create-react-app/packages/react-scripts/scripts/start.js Lines 22 to 32 in d5c0fe2
|
Without |
I have another version of this. After adding
|
It works for me too! |
I also got that too. Just figured out that I have to change "compilerOptions": {
"jsx": "react",
"noFallthroughCasesInSwitch": true
} |
How do you suggest to edit |
This also updates to React 17, eslint 7, TypeScript v4, etc. - React 17 has no new features, but does have a few breaking changes that shouldn't affect bsd. (https://reactjs.org/blog/2020/10/20/react-v17.html) - eslint 7 and the updated config caused a minor issue (https://stackoverflow.com/a/64024916/549363) - react-scripts v4 seems to have a bug while validating TS config, which this commit works around (facebook/create-react-app#9429)
You can create a new
|
I've tried adding
Thanks for this, confirming it worked for me too! On its own, |
Yeah for evreyone else I can confirm that it works only when both changes listed above are applied |
@flppv It still doesn't solve the "paths", because that's an object and no just primitive value. I am surprised they published 4.0.0 without handling such a "major" flaw. |
That is right, paths property still not allowed in 4.0.0, that's a bummer for monorepo setup 😕 |
about `"noFallthroughCasesInSwitch": true`: facebook/create-react-app#9429
@FredyC I use a temporary solution (see above how I update the file node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js) |
@wooandoo I know, but I still don't get it why the team decided to be this string. The path aliases work with CRA just fine, so why to prevent it? @ianschmitz Also notice the number of 👍 in my previous #9429 (comment). Obviously, I am not the only one concerned about it. At least tell us if we need open new issue or if this is somehow being still decided or what. Please don't ignore it. |
@FredyC does the fix not work for paths? |
Setting |
@ianschmitz I honestly haven't tried, but seeing 30+ people giving 👍 and seeing this still present in the code, I don't think it's handled :)
|
React-scripts has been upgraded. The tsconfig had to be edited in order to bypass an error. Ref: facebook/create-react-app#9429 (comment)
Don't really get why this was closed when this is still breaking when upgrading from an existing project to CRA 4. |
Is there any reason why path alias is tsconfig.json? This should be a very useful feature. |
Delete the "tsconfig.json" file, then run "npm start" or "yarn start" |
When I write "paths: { ... }" in |
Upgraded from This helped #9429 (comment) Deleting Looks like the fix has been merged but not released yet #9921 |
#9921 is included with |
Also faced error
P.S. I'd also tried to set up |
Error Message: TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible Issue: facebook/create-react-app#9429
Swapping the |
So I had the This led to another error: Now it shows |
Describe the bug
I updated a typescript CRA project (previously on
^3.4.0
react-scripts version) to use react-scripts "next" version to try out 4.0 alpha (following https://gist.github.com/iansu/282dbe3d722bd7231fa3224c0f403fa1), but encountered this error when runningyarn start
Did you try recovering your dependencies?
(Write your answer here.)
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
Steps to reproduce
(Write your steps here:)
next
version of react-scripts inpackage.json
yarn
to install new depsyarn start
Expected behavior
Expected
yarn start
to work as before.Actual behavior
Has console output (see above).
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered: