I just ported one app from create-react-app-typescript
to create-react-app
. In a identically structured but different app, I did the same steps.
npm uninstall react-scripts-ts
npm install react-scripts
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
Detailed Steps
src/react-app-env.d.ts
The generated file src/react-app-env.d.ts
causes the --isolatedModules
error.
How do I prevent react-scripts
from generating the src/react-app-env.d.ts
file upon react-scripts start
?
Next, there is a new react-app-env. d. ts file in the src folder. This file references TypeScript types declarations that are specific to projects started with Create React App. These type declarations add support for importing resource files such as bmp, gif, jpeg, jpg, png, webp, and svg.
Create react app is basically a node package that we can simply install. The interesting part about this is that you can use it with TypeScript very easily by leveraging the use of npm or yarn depending on what your package manager preference is.
Useful info:
As expected there was an empty file causing an issue, but it was not the generated src/react-app-env.d.ts
file.
Personal context:
An automated watch script copied an empty file into the problem project. The automated scripts never clean the destination, so the empty file hung around and later caused this issue.
Make sure there are no empty (.ts) files.
While this is the actual answer in the sense that it solved my problem, I still don't know why one project generates a src/react-app-env.d.ts
file while the other does not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With