Fireship · @fireship
How to use TypeScript with React... But should you?
Uploaded April 19, 2021 · Length 6:36
Summary
Fireship discusses whether to use TypeScript with React, weighing pros and cons, and how to get started with TypeScript and React.
- typescript with react
- typescript pros and cons
- typescript getting started
- react development
- javascript
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
when I started this YouTube channel four
- 0:01
years ago most react developers would
- 0:03
have laughed at the idea of using
- 0:04
something like typescript you should
- 0:07
you should nah bro like why would you
- 0:09
take your beautiful functional
- 0:10
JavaScript and bloat it with a bunch of
- 0:11
type definitions that make it look like
- 0:13
the real Jabba I was very skeptical of
- 0:15
it myself when I first started using it
- 0:17
in an angular project in 2017. now maybe
- 0:19
it's just the Stockholm syndrome talking
- 0:21
but after using it I've never wanted to
- 0:23
go back but I don't think I'm alone
- 0:24
because it was the second most loved
- 0:25
technology on the 2020 stack Overflow
- 0:28
survey in today's video you'll learn
- 0:29
everything you need to know to get
- 0:30
started with typescript and react but
- 0:32
more importantly we'll talk about why or
- 0:34
why not you should use it because
- 0:36
there's a good case to be made for both
- 0:37
sides of that argument if you're new
- 0:39
here like And subscribe and become a pro
- 0:41
member at fireship i o to get access to
- 0:43
my full next JS react course to decide
- 0:45
whether or not you want to use
- 0:46
typescript let's take a look at two
- 0:48
different projects side by side one with
- 0:50
typescript and one without there are
- 0:51
many different ways to add typescript to
- 0:53
a react app in this case I'm using the
- 0:55
create react app tool but specifying the
- 0:57
typescript template the docs also have
- 0:59
instructions for adding it to an
- 1:01
existing project or you can learn how to
- 1:03
set it up in next.js in my course if we
- 1:05
look at the file system on these two
- 1:06
projects side by side the most obvious
- 1:08
difference is that the typescript
- 1:10
project has files ending in dot TS or
- 1:12
dot TSX but the weird thing is that if
- 1:15
we look inside one of these files the
- 1:16
code is exactly the same as the
- 1:18
Javascript file and that actually brings
- 1:20
up a good question what is typescript if
- 1:22
my code is exactly the same typescript
- 1:24
as a language is a superset of
- 1:25
JavaScript that means vanilla JavaScript
- 1:27
is also 100 valid typescript in other
- 1:30
words it just adds extra optional
- 1:32
features on top of regular JavaScript
- 1:34
the relationship between scss and CSS is
- 1:37
the same as typescript and JavaScript
- 1:39
and that's really cool because it means
- 1:41
you don't really have to learn anything
- 1:42
to get started with it but here's the
- 1:44
catch browsers don't know how to run
- 1:46
typescript code what is this crap which
- 1:48
means that we need a compiler to take
- 1:50
our typescript code and transpile it or
- 1:53
compile it down to regular JavaScript in
- 1:55
our TS project you'll notice a special
- 1:57
file called tsconfig its purpose is to


