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

Poor documentation of what it means to use --typescript option #5939

Closed
theconnectionist opened this issue Dec 1, 2018 · 10 comments
Closed

Comments

@theconnectionist
Copy link

I was excited to see the new --typescript option. Used it to create a project, but there was no evidence that typescript support was added. Then I discovered a documentation page suggesting I should rename .js to .tsx and restart the server. Did that, but got the following error. Not clear why this is happening if I already created a project with --typescript option. The whole point of using create-react-app (for a newbie react developer) is to get started without messing with any configuration, but adding typescript support doesn't look straightforward.

Appreciate any help with clear instructions on what --typescript actually does. If it isn't creating the scaffolding for typescript, should I follow instructions to add typescript support to an existing create-react-app?

`We detected TypeScript in your project (src/App.tsx) and created a tsconfig.json file for you.

It looks like you're trying to use TypeScript but do not have typescript installed.
Please install typescript by running npm install typescript.
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files).`

@iansu
Copy link
Contributor

iansu commented Dec 1, 2018

There's an open PR that adds better documentation for the --typescript flag: #5866

@Timer
Copy link
Contributor

Timer commented Dec 1, 2018

"create a project, but there was no evidence that typescript support was added"

Have you updated your Create React App CLI tool?

This is required for it to scaffold with TypeScript files.

@theconnectionist
Copy link
Author

Timer, I think you are asking if I created a new create-react-app. I created a new one using "npx create-react-app --typescript". Just upgraded to latest npx on windows and have the same problem I reported last night. That first report was based on an install on a Mac (with a recently updated npm/npx).

If you meant something else, please elaborate what I should do to "update my Create React App CLI tool". I started with a new project.

@Timer
Copy link
Contributor

Timer commented Dec 1, 2018

npx will sometimes use a cached, old version. Can you run npx create-react-app --version and post the output?

@Timer
Copy link
Contributor

Timer commented Dec 1, 2018

Also, make sure you run npx create-react-app my-app --typescript and NOT npx create-react-app --typescript my-app.

@theconnectionist
Copy link
Author

npx create-react-app --version
1.5.1

This is a fresh install of npx, so no cache was involved. Yes, I made sure --typescript was at the end.

@theconnectionist
Copy link
Author

Ok, I see the latest version is 2.1.1, but somehow I got 1.5.1. I'll read up on how to banish cached older versions and report back.

@theconnectionist
Copy link
Author

I force flushed my npm cache on the windows box, but npx continued to report version 1.5.1. So I tried this on my Ubuntu box and it got version 2.1.1 and use of "--typescript" indeed installed typescript and setup .tsx files instead of .js.

Now I have to go back to the Mac where I first ran into this problem and figure out why it got stuck with an older version of create-react-app.

@Timer
Copy link
Contributor

Timer commented Dec 1, 2018

Maybe try npm init react-app my-app --typescript?

@adjohnston
Copy link

adjohnston commented Dec 25, 2018

I found that I had an older version installed via Yarn, installed globally. Uninstalling it fixed my issues with NPX.

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants