4
votes

When I executed command in cmd:

npx create-react-app my-app --typescript

It's seems like app will be typescript but when I open folder in VS-code then I release that all files in src folder are with .js extension instead .ts(.tsx) extensions.. I try to create app by cmd(administrator mode) but useless, without change. Also I tried with command:

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

Still nothing.

There are no error. App works like standard react+js app.

3

3 Answers

3
votes

Try:

npx create-react-app my-app --scripts-version=react-scripts-ts

or:

yarn create react-app my-app --scripts-version=react-scripts-ts
0
votes

Worked for me, did you try npm uninstall -g create-react-app first? this will of course uninstall create-react-app globally

Ading Typescript

0
votes

I also got the same error, and tried npx create-react-app my-app --scripts-version=react-scripts-ts as advised above and got the error below:

✔ The react-scripts-ts package is deprecated. TypeScript is now supported natively in Create React App. You can use the --template typescript option instead when generating your app to include TypeScript support. Would you like to continue using react-scripts-ts? … yes Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts-ts with cra-template...

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at: npm ERR! https://npm.community

I then removed create-react-app globally using the below command sudo npm uninstall -g create-react-app

Then

npx create-react-app my-app --template typescript and all works well

refer to his guide enter link description here