-
-
Notifications
You must be signed in to change notification settings - Fork 27k
tsconfig.json gets overwritten the moment the CRA typescript project is closed and opened in VSCode #10178
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
Comments
I noticed that when I build my project, I see:
But if it's set to "react-jsx" I get a bunch of errors with the following:
FWIW, I'm on Typescript |
@denchen yes. it looks like that. Now if you use the quick fix feature to fix the error, and it will actually change the tsconfig.json to apply this fix:
However, when you close the project and reopen, you will see that the tsconfig.json is reset automatically by VS Code!. |
The changes made to tsconfig.json automatically gets reset as and when I close and reopen my vscode ! Strange that my changes are saved in the first go but later gets reset without any consent ! Seems to be a bug in the firstlook ! |
Even I noticed that when I reopen my project, tsconfig.json file automatically get resets by VS Code!. I modify and save the tsconfig.json file But, when reopen the project, tsconfig.json is reset back to |
I am also facing same issue, tsconfig.json file is overwritten once I close and reopen the vscode project. |
I modified and saved tsconfig.json file. But gets overwritten once i close and reopen VS Code!. |
Yes! I have the same issue |
Facing the same issue. Once I close and reopen the VS Code the tsconfig.json file gets overwritten. |
Yes I'm facing the same issue since a while. Any modifications made to the tsconfig.json file will be reset to defaults once VScode is closed and reopened. |
I am facing same issue too! In my case, any changes made in tsconfig.json file is lost once my project in vscode is closed and reopened. |
I am facing the same issue.I had done changes in my tsconfig.json file and saved them, but when the vscode is closed and reopened the changes that i had done were lost. |
I am facing the similar issue. When I reopen the Vscode the modification made in tsconfig.json gets lost. |
I am facing the same issue.Tsconfig.json file gets overwritten once I close and reopen the vscode project. |
I am facing an issue, tsconfig.json file gets overwritten and modification made will be lost in the VScode project as and when i close and reopen |
I am facing the same issue, tsconfig.json file is overwritten and changes made are lost once I close and reopen the project in vscode |
Happens in both VSCode and SublimeCode 3 - no possibility to persist |
I don't even need to close and open VS Code, it will happen as I'm coding. I've seen it happen while the tsconfig.js file open in my view. Odd |
|
Setting |
I'm facing a similar issue, but with the "compilerOptions" -> "paths". It looks like the problem is when project you run "npm start" or the "yarn start". |
I created a new project.
I navigated to the directory, installed the dependencies and then started the project. The webapp runs. However, when I open the example app in VSCode, it gives me errors. See screenshot below. Can we please get a fix for this? |
Hey brother. I just fix this. Because the typescript version, you can see it here 。 I see your typescript perhaps used the vscode default version, so you can change typescript version to the create-react-app default version, just like this。 |
Guys if you see an error |
In my case I just wanted to set import alias for TS. Faced with the same issue. fixed by ejecting the app. |
Also reverting typescript to 3.9.9 to fix issue described here facebook/create-react-app#10178
* Removing the extra .eslintrc * Updating react-scripts and eslint peer dependencies Also reverting typescript to 3.9.9 to fix issue described here facebook/create-react-app#10178
thanks,i set it,now it is correct |
Here's your work around, but before I get there... Dear Maintainers: Occasionally, people need to work around things by modifying aliases. Its a tsconfig file... its my config, not yours. It's committed code. If you don't like it, throw a warning, hell, even throw an error with an override flag. This is just dumb. Really wanna get aggressive? Write out a new fixed.tsconfig.json. That would get our attention. Now, workaround. create a tsconfig.base.json - add your changes there. In my case it was typing overrides because yup wasn't happy with what I was using.
On your tsconfig.json, pull it in as an import.
|
Thank you @givethemheller !!! Your solution worked for me! |
That solution did not work for me, I'm not sure why not. |
Thank you @givethemheller !!! Your solution worked for me! |
Can't believe that this issue is still not fixed... |
any updates on this? |
TL;DR quick hack: In function verifyTypeScriptSetup() { to function verifyTypeScriptSetup() {
return; Longer version: As others have said here, this rewriting of Anyway... like the OP, I needed That led me to my nuclear option (without ejecting)... neuter the script that runs this rewriting logic. It turned out to be extremely simple. The following is for
Of course, if you update Note: The |
@lcdennison Great explanation! I’m also wondering if these lines should give us some information. But actually I’ve never seen it works. create-react-app/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js Lines 263 to 285 in f0a837c
|
I found a StackOverflow question that points to a possibility that Microsoft has some documentation on how to target the workspace version instead of the VSCode version of TypeScript here: https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript |
Same problem, can't solve selecting the workspace version.
|
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Still having this issue. @givethemheller's solution doesn't work for me.
|
same here... Wanted to try esbuild :\ |
Same issue |
Same thing here, I didn't understand why changes I made to the tsconfig file were been overwritten until I found this bug report. I'm still on version 4.x.x has this been fixed on 5.x.x? |
Describe the bug
All your changes to tsconfig.json in a CRA typescript project will be lost the moment you close and open your project in VSCode.
Note that, I do not run any commands like yarn start, etc yet.
tsconfig.json is automatically getting overwritten the moment project is closed and reopened!.
Which terms did you search for in User Guide?
I searched resetting tsconfig.json upon closing and opening CRA typescript project. All I could see is about recent issues where the tsconfig.json getting overwritten when we run npm run start.
#8614
Environment
current version of create-react-app: 4.0.1
running from /Users/shripada/.npm/_npx/25537/lib/node_modules/create-react-app
System:
OS: macOS 10.15.7
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 12.16.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 87.0.4280.67
Edge: Not Found
Firefox: 83.0
Safari: 14.0.1
npmPackages:
react: ^17.0.1 => 17.0.1
react-dom: ^17.0.1 => 17.0.1
react-scripts: 4.0.1 => 4.0.1
npmGlobalPackages:
create-react-app: Not Found
VSCode
Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-11T01:11:34.018Z (2 wks ago)
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0
Steps to reproduce
(Write your steps here:)
The project opens in VSCode. and the package.json will look with these deps installed:
Save tsconfig.json. Observe that the changes are saved.
is reset back to the default:
Note that, we have not run any other commands like yarn start, etc. tsconfig.json is automatically getting overrwritten the moment project is closed and reopened!.
Also note that, if I delete node_modules and then make changes to tsconfig.json, close and open project, VSCode does not overwrite the tsconfig.json
Expected behavior
tsconfig.json file retains any changes made between closing and reopening of the project. VSCode does not automatically overwrite this file upon reopening.
Actual behavior
tsconfig.json gets overwritten when we close the project and open it again.
Reproducible demo
Please refer the project:
https://github.com/shripada/testts
The text was updated successfully, but these errors were encountered: