I decided to use React JS with TypeScript. Doing a simple hello world project. Referring two books, and they both suggest the following. Brand new project, not upgrading or any of those scenarios. Starting fresh.
npx create-react-app try-react -–template typescript
That works fine.
But, the files, they still have the .js extension. In the book, one of them has a screenshot, it is already with .tsx extension.
I have looked at this link, https://create-react-app.dev/docs/adding-typescript/. It says,
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
Global installs of create-react-app are no longer supported.
So, I removed the global install. tried again.
Same thing. no files with .tsx extension. The book author does not mention anything about having to rename these files manually.
So, my question is,
I had the same problem. What solved it for me:
npm install cra-template-typescript
For some reason the template was not there for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With