5

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 Answers 3

3

Try:

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

or:

yarn create react-app my-app --scripts-version=react-scripts-ts
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! App start without any problem, but file App.tsx show me some error in code, something like "unreacheble code detection"?
1

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

Comments

0

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

Ading Typescript

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.