In trying to update the TypeScript React Starter, I'm trying to leverage the newly supported support in CRA; however, running create-react-app with the --typescript flag seems to not do anything, and the process of adding TypeScript in general has a bit of friction.
As an example, I ran
npx create-react-app myapp --typescript
I expected at least the following:
- My files should have been
.ts/.tsx files.
- A prescriptive
tsconfig.json file should have been given to me out of the box.
- My devDependencies should have included
typescript, @types/react, and @types/react-dom.
Instead,
- The
--typescript flag didn't do anything special, and I had to rename a file like App.js to App.tsx before yarn start gave me a tsconfig.json.
yarn start told to run yarn add typescript after the rename (which is misleading since it should be a devDependency - so yarn add -D typescript).
- Running
yarn start one more time, I was given a type-error because I was missing @types/react and @types/react-dom as devDependencies.
Then everything worked, but this feels extremely frictiony. And it's also fairly confusing, because this flag doesn't seem to give anything beyond what the standard CRA scaffolding gives. And other issues have pointed this out too:
In trying to update the TypeScript React Starter, I'm trying to leverage the newly supported support in CRA; however, running
create-react-appwith the--typescriptflag seems to not do anything, and the process of adding TypeScript in general has a bit of friction.As an example, I ran
I expected at least the following:
.ts/.tsxfiles.tsconfig.jsonfile should have been given to me out of the box.typescript,@types/react, and@types/react-dom.Instead,
--typescriptflag didn't do anything special, and I had to rename a file likeApp.jstoApp.tsxbeforeyarn startgave me atsconfig.json.yarn starttold to runyarn add typescriptafter the rename (which is misleading since it should be adevDependency- soyarn add -D typescript).yarn startone more time, I was given a type-error because I was missing@types/reactand@types/react-domasdevDependencies.Then everything worked, but this feels extremely frictiony. And it's also fairly confusing, because this flag doesn't seem to give anything beyond what the standard CRA scaffolding gives. And other issues have pointed this out too: