question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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):

  1. Honor the new location of react-app-env.d.ts if we move it.
  2. Allow us to configure where this file goes.
  3. 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:open
  • Created 5 years ago
  • Reactions:198
  • Comments:42 (3 by maintainers)

github_iconTop GitHub Comments

190reactions
bugzpoddercommented, Jun 19, 2019

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.

81reactions
iansucommented, Jun 20, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found