Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading statement regarding using Create-React-App with Typescript #1482

Closed
carpben opened this issue Dec 11, 2018 · 3 comments
Closed

Misleading statement regarding using Create-React-App with Typescript #1482

carpben opened this issue Dec 11, 2018 · 3 comments

Comments

@carpben
Copy link

carpben commented Dec 11, 2018

In static-type-checking -> Using TypeScript with Create React App it says

Create React App supports TypeScript out of the box.

Well, it doesn't seem so.
I followed the instructions for creating a new project.
create-react-app my-app --typescript
I converted App.jsx to App.tsx. There was only 1 error - no types for React. I installed types for React
npm i @types/react
and then run npm start.
I got the following error:
image
While it's perfectly fine to expect a user to install "typescript" and the various type modules, i wouldn't say that it qualifies as "support out of the box" for typescript.

@liamross
Copy link

If you run npx create-react-app my-app --typescript it will generate your entire project using typescript, so the App file will be App.tsx, and there should be no reason to have to change it from .jsx to .tsx. I just attempted this myself and it seems to be the case. I'd recommend you try again with the command and see if you run into the same issues.

To summarize: if you run npx create-react-app my-app --typescript it will generate create-react-app with typescript already set up, no need to install anything further or change any files.

@carpben
Copy link
Author

carpben commented Jan 6, 2019

This is not my experience. I just tried both npx create-react-app my-app --typescript and just create-react-app my-app --typescript. In both cases I got the same regular template of create-react-app, with index.js, and app.js. @types/react was not a dependency, and it did not recognize the type of a React component. my react scripts version is "react-scripts": "2.1.3"

@carpben
Copy link
Author

carpben commented Jan 6, 2019

I just updated create-react-app, and it solved the problem.

The reason I did not update create-react-app in the first place is that I read here (Create-React-App documenation) that :

You almost never need to update create-react-app itself: it delegates all the setup to react-scripts.

When you run create-react-app, it always creates the project with the latest version of react-scripts so you’ll get all the new features and improvements in newly created apps automatically.

I'll close this here, and open an issue on Create-React-App.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants