Friction in TypeScript setup experience
Created by: DanielRosenwasser
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 likeApp.js
toApp.tsx
beforeyarn start
gave me atsconfig.json
. -
yarn start
told to runyarn add typescript
after the rename (which is misleading since it should be adevDependency
- soyarn 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
asdevDependencies
.
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: