question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Friction in TypeScript setup experience

See original GitHub issue

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:

  1. My files should have been .ts/.tsx files.
  2. A prescriptive tsconfig.json file should have been given to me out of the box.
  3. My devDependencies should have included typescript, @types/react, and @types/react-dom.

Instead,

  1. 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.
  2. 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).
  3. 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:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ianschmitzcommented, Jan 5, 2019

If you’re using npx, make sure you don’t have create-react-app installed globally, as it will used the installed version i believe.

npm uninstall -g create-react-app

1reaction
mccombsrcommented, Jan 5, 2019

@ianschmitz You were right, I globally uninstalled create-react-app (and typescript just to be safe) and it worked this time around! Thanks for the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

User Experience Friction in Real Life Examples | Code & Pepper
User experience friction can kill a brilliant idea for an app. Learn what it is, when and why avoid it, and how to...
Read more >
4 Easy Ways to Start Playing with TypeScript - Decembersoft Inc.
Undoubtedly, learning is easiest when there is no friction. Here are some easy ways to get your toes wet with TypeScript before you...
Read more >
Documentation - Modules - TypeScript
Exporting a declaration ... Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export...
Read more >
Using TypeScript with React - DigitalOcean
This tutorial covers how to use TypeScript with React functional or class-based components. In this post we also make use of the Parcel ......
Read more >
Migrating millions of lines of code to TypeScript - Stripe
In late 2020, we formed a new horizontal JavaScript Infrastructure team: a group of engineers solely focused on elevating the experience of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found