Stop putting react-app-env.d.ts in src
See original GitHub issue(This pertains to CRA w/ the --typescript flag
.)
Putting a loose d.ts file at the top level of src adds clutter and breaks the convention of putting all d.ts files together in a folder, such as “types”.
Suggestions to remedy this (in order of preference):
- Honor the new location of react-app-env.d.ts if we move it.
- Allow us to configure where this file goes.
- Place the file in src/types.
EDIT:
@nhooyr Given its confusing, you could also add a comment to the generated file explaining why its there.
@bugzpodder This file was created to include create-react-app specific types. Removing it will cause errors like:
TypeScript error in ~/src/App.tsx(2,18):
Cannot find module './logo.svg'. TS2307
1 | import React from 'react';
> 2 | import logo from './logo.svg';
| ^
3 | import './App.css';
4 |
5 | const App: React.FC = () => {
This was created from #5611 if you want more details.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:198
- Comments:42 (3 by maintainers)
Top Results From Across the Web
Create React App (TypeScript) auto-generating react-app-env ...
The generated file src/react-app-env.d.ts causes the --isolatedModules error. Actual Question: How do I prevent react-scripts from generating ...
Read more >Migrating from Create React App (CRA) to Vite
Learn how to migrate your CRA app over to Vite. ... Since we're using Typescript, we need to create a vite-env.d.ts file under...
Read more >Env Variables and Modes - Vite
During production, these env variables are statically replaced. It is therefore necessary to always reference them using the full static string.
Read more >How to Start New React Application with Create React App ...
Do not remove the react-app-env.d.ts file to avoid errors. Source code#. All JavaScript code files in the src folder will ...
Read more >Create React App (TypeScript) auto-generating ... - iTecNote
The generated file src/react-app-env.d.ts causes the --isolatedModules error. Actual Question: How do I prevent react-scripts from generating the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t really see this as a blocker for anyone. Having an extra file isn’t ideal but it’s pretty minimal by itself.
@devuxer No, being a “blocker” is not a requirement for submitting an issue. However, following the code of conduct and being respectful to people is.