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.

Adding TypeScript to existing project does not add tsconfig

See original GitHub issue

Describe the bug

If you follow https://create-react-app.dev/docs/adding-typescript and attempt to add TypeScript to existing project using

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

The resulting changes will obviously not include tsconfig, unlike newly created projects and contrary to next section of manual.

Environment

create-react-app: 4.0.3

Steps to reproduce

npx create-react-app my-app
cd my-app
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
cat tsconfig.json

Expected behavior

Default tsconfig.json file is added to the project if you follow documentation.

Actual behavior

No tsconfig.json 😦

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:19
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
laurmurclarcommented, Feb 15, 2022

I’m also seeing this problem when trying to add TS to an existing app

npx create-react-app --info

Environment Info:

  current version of create-react-app: 5.0.0
  running from /Users/lauramurphy-clarkin/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: macOS 11.6.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 16.9.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 7.21.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Edge: Not Found
    Firefox: 97.0
    Safari: 15.3
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

As a workaround, I created a new react app by running: npx create-react-app ts-example --template typescript And then copy-pasted the contents of the generated tsconfig.json into my existing app.

7reactions
schrikercommented, Jan 25, 2022

I have the same problem used to create a new app:

npx create-react-app my-app
cd my-app
npm install --save typescript @types/node @types/react @types/react-dom @types/jest

Renamed files to .tsx and .ts run npm start and scripts don’t seem to detect that I’m trying to use TS because no tsconfig.json is created. Have to create it manually to make it works.

Node: v16.13.0 NPM: 8.3.2 System: MacOS

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding TypeScript to existing create-react-app app
Create a temporary project with react-scripts-ts · Copy tsconfig.json , tsconfig.test.json , tslint. · In package.json , change all the references ...
Read more >
Adding typescript to the existing react project
This note will help you understand how to add typescript to an existing Create React App project and start writing new files in...
Read more >
Adding TypeScript | Create React App
To add TypeScript to an existing Create React App project, ... You are not required to make a tsconfig.json file, one will be...
Read more >
Use Typescript in an already existing create-react-app Project
Adding Typescript to your Javascript code · Change a javascript extension file .js to a typescript extension .ts or if the file extension...
Read more >
How to set up TypeScript
Add TypeScript to your project, or install TypeScript globally. ... For project types which don't support Nuget, you can use the TypeScript Visual...
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