14

Context:

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.

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

Problems unique to second app:

  • Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. TS1208
  • Generated file src/react-app-env.d.ts

Assumption:

The generated file src/react-app-env.d.ts causes the --isolatedModules error.

Actual Question:

How do I prevent react-scripts from generating the src/react-app-env.d.ts file upon react-scripts start?

3 Answers 3

5

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.

Actual answer:

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm having the same problem in that I am moving from create-react-app-typescript to create-react-app and it's generating the file you mentioned. I don't have any empty .ts files, so I'm wondering why this is happening...
Having the same issue as @Tur1ng, no empty files.
3

This is a known bug. React team has not yet fixed it. For now you can ignore this file by adding following inside .gitignore

/src/react-app-env.d.ts

For more details checkout https://github.com/facebook/create-react-app/issues/6560

1 Comment

You should NOT add it to .gitignore. github.com/facebook/create-react-app/issues/…
0

I just deleted react-app-env.d.ts and I stopped getting the error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.