Learn the basics if TypeScript in 100 Seconds! If you love TS, upgrade to Fireship PRO for 40% off using code mbus5Kcj at https://fireship.io/pro

TypeScript docs https://www.typescriptlang.org/

#typescript #js #100SecondsOfCode

Install the quiz app 🤓

iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.google.com/store/apps/details?id=io.fireship.quizapp

My VS Code Theme

- Atom One Dark 
- vscode-icons
- Fira Code Font
2024-02-04T06:02:11.172Z
nova-2
2-general-nova
2024-01-09.29447
30089e05-99d1-4376-b32e-c263170674af
92041678-5b63-45b3-a73a-f615fdfb9923
b02082538c71d50e988a2a091431635f9eb947b94b007d3c9d61a07fe98ab165
67875a7f-c9c4-48a0-aa55-5bdb8a91c34a
deprecated
TypeScript.
Validate your JavaScript ahead of time with static type checking.
JavaScript is a dynamic language where we can do all kinds of crazy things, like reference variables that don't exist or work with objects of an unknown shape.
The code is interpreted by a browser, but if your code is broken, you won't catch it until run when the browser throws an error.
TypeScript prevents errors like this from ever happening by extending JavaScript with types.
The language is a strict superset of script, which means when you open up a TS file, you can write plain JavaScript with all of its extra features being completely optional.
But notice in the code here how the IDE is providing feedback about using a variable that doesn't exist.
Instead of fixing this issue weeks later in a stack trace after the company loss 1,000,000 of dollars.
We can fix it right here, right now.
The reason we get this instant feedback is because TypeScript behaves like a compiled language, where JavaScript is the compilation target.
You can run the TypeScript compiler using the tsc command.
It will take the TS file and transpile it into vanilla JavaScript.
And you can choose any flavor of JavaScript you want if you need to target ancient browsers.
And that means you can use the latest and greatest syntax features of JavaScript without having to worry if They'll be supported in an older environment.
Your TypeScript project will likely have a tsconfig file, which provides an infinite number of ways to customize the behavior of the compiler.
But the primary goal of TypeScript is to enable static typing.
One way it achieves that is by allowing you to annotate your code with types.
We can strongly type a variable using a colon followed by its type, like a string, Boolean, or number.
That's known as an explicit type.
If we then try to assign its value as the wrong type, we get an error.
Alternatively, if we set an initial value, it will implicitly infer the type.
However, there may be cases where you want to opt out of this behavior, in which case, you can annotate with the any type.
That allows you to loosely type or opt out of type checking.
When working with an array, use brackets to strongly type a list.
In addition, you can define your own custom types and interfaces, which is especially powerful when working with objects.
The car interface here defines various types of the properties on an object.
We can then apply the interface to a plain JavaScript Object.
The beauty of having strongly typed code is that we get autocomplete everywhere in our IDE.
We don't have to jump back and forth to documentation or dig through stack traces to figure out wire code's not working.
If you like TypeScript as much as I do, consider becoming a pro member at FireShip IO.
For the next few days, everything will be 40% off, including lifetime memberships.
Thanks for watching, and I will see you in the next one.

Speaker 0: TypeScript. Validate your JavaScript ahead of time with static type checking. JavaScript is a dynamic language where we can do all kinds of crazy things, like reference variables that don't exist or work with objects of an unknown shape. The code is interpreted by a browser, but if your code is broken, you won't catch it until run when the browser throws an error. TypeScript prevents errors like this from ever happening by extending JavaScript with types.

The language is a strict superset of script, which means when you open up a TS file, you can write plain JavaScript with all of its extra features being completely optional. But notice in the code here how the IDE is providing feedback about using a variable that doesn't exist. Instead of fixing this issue weeks later in a stack trace after the company loss 1,000,000 of dollars. We can fix it right here, right now. The reason we get this instant feedback is because TypeScript behaves like a compiled language, where JavaScript is the compilation target.

You can run the TypeScript compiler using the tsc command. It will take the TS file and transpile it into vanilla JavaScript. And you can choose any flavor of JavaScript you want if you need to target ancient browsers. And that means you can use the latest and greatest syntax features of JavaScript without having to worry if They'll be supported in an older environment. Your TypeScript project will likely have a tsconfig file, which provides an infinite number of ways to customize the behavior of the compiler.

But the primary goal of TypeScript is to enable static typing. One way it achieves that is by allowing you to annotate your code with types. We can strongly type a variable using a colon followed by its type, like a string, Boolean, or number. That's known as an explicit type. If we then try to assign its value as the wrong type, we get an error.

Alternatively, if we set an initial value, it will implicitly infer the type. However, there may be cases where you want to opt out of this behavior, in which case, you can annotate with the any type. That allows you to loosely type or opt out of type checking. When working with an array, use brackets to strongly type a list. In addition, you can define your own custom types and interfaces, which is especially powerful when working with objects.

The car interface here defines various types of the properties on an object. We can then apply the interface to a plain JavaScript Object. The beauty of having strongly typed code is that we get autocomplete everywhere in our IDE. We don't have to jump back and forth to documentation or dig through stack traces to figure out wire code's not working. If you like TypeScript as much as I do, consider becoming a pro member at FireShip IO.

For the next few days, everything will be 40% off, including lifetime memberships. Thanks for watching, and I will see you in the next one.
TypeScript. Validate your JavaScript ahead of time with static type checking. JavaScript is a dynamic language where we can do all kinds of crazy things, like reference variables that don't exist or work with objects of an unknown shape.
The code is interpreted by a browser, but if your code is broken, you won't catch it until run when the browser throws an error. TypeScript prevents errors like this from ever happening by extending JavaScript with types. The language is a strict superset of script, which means when you open up a TS file, you can write plain JavaScript with all of its extra features being completely optional.
languages
But notice in the code here how the IDE is providing feedback about using a variable that doesn't exist. Instead of fixing this issue weeks later in a stack trace after the company loss 1,000,000 of dollars. We can fix it right here, right now. The reason we get this instant feedback is because TypeScript behaves like a compiled language, where JavaScript is the compilation target.
programming
You can run the TypeScript compiler using the tsc command. It will take the TS file and transpile it into vanilla JavaScript. And you can choose any flavor of JavaScript you want if you need to target ancient browsers. And that means you can use the latest and greatest syntax features of JavaScript without having to worry if They'll be supported in an older environment.
Your TypeScript project will likely have a tsconfig file, which provides an infinite number of ways to customize the behavior of the compiler. But the primary goal of TypeScript is to enable static typing. One way it achieves that is by allowing you to annotate your code with types. We can strongly type a variable using a colon followed by its type, like a string, Boolean, or number. That's known as an explicit type. If we then try to assign its value as the wrong type, we get an error.
programming
Alternatively, if we set an initial value, it will implicitly infer the type. However, there may be cases where you want to opt out of this behavior, in which case, you can annotate with the any type. That allows you to loosely type or opt out of type checking. When working with an array, use brackets to strongly type a list. In addition, you can define your own custom types and interfaces, which is especially powerful when working with objects. The car interface here defines various types of the properties on an object. We can then apply the interface to a plain JavaScript Object. The beauty of having strongly typed code is that we get autocomplete everywhere in our IDE. We don't have to jump back and forth to documentation or dig through stack traces to figure out wire code's not working. If you like TypeScript as much as I do, consider becoming a pro member at FireShip IO. For the next few days, everything will be 40% off, including lifetime memberships. Thanks for watching, and I will see you in the next one.
TypeScript. Validate your JavaScript ahead of time with static type checking. JavaScript is a dynamic language where we can do all kinds of crazy things, like reference variables that don't exist or work with objects of an unknown shape. The code is interpreted by a browser, but if your code is broken, you won't catch it until run when the browser throws an error. TypeScript prevents errors like this from ever happening by extending JavaScript with types. The language is a strict superset of script, which means when you open up a TS file, you can write plain JavaScript with all of its extra features being completely optional. But notice in the code here how the IDE is providing feedback about using a variable that doesn't exist. Instead of fixing this issue weeks later in a stack trace after the company loss 1,000,000 of dollars. We can fix it right here, right now. The reason we get this instant feedback is because TypeScript behaves like a compiled language, where JavaScript is the compilation target. You can run the TypeScript compiler using the tsc command. It will take the TS file and transpile it into vanilla JavaScript. And you can choose any flavor of JavaScript you want if you need to target ancient browsers. And that means you can use the latest and greatest syntax features of JavaScript without having to worry if They'll be supported in an older environment. Your TypeScript project will likely have a tsconfig file, which provides an infinite number of ways to customize the behavior of the compiler. But the primary goal of TypeScript is to enable static typing. One way it achieves that is by allowing you to annotate your code with types. We can strongly type a variable using a colon followed by its type, like a string, Boolean, or number. That's known as an explicit type. If we then try to assign its value as the wrong type, we get an error. Alternatively, if we set an initial value, it will implicitly infer the type. However, there may be cases where you want to opt out of this behavior, in which case, you can annotate with the any type. That allows you to loosely type or opt out of type checking. When working with an array, use brackets to strongly type a list. In addition, you can define your own custom types and interfaces, which is especially powerful when working with objects. The car interface here defines various types of the properties on an object. We can then apply the interface to a plain JavaScript Object. The beauty of having strongly typed code is that we get autocomplete everywhere in our IDE. We don't have to jump back and forth to documentation or dig through stack traces to figure out wire code's not working. If you like TypeScript as much as I do, consider becoming a pro member at FireShip IO. For the next few days, everything will be 40% off, including lifetime memberships. Thanks for watching, and I will see you in the next one.
TypeScript.
typescript
Validate
validate
your
your
JavaScript
javascript
ahead
ahead
of
of
time
time
with
with
static
static
type
type
checking.
checking
JavaScript
javascript
is
is
a
a
dynamic
dynamic
language
language
where
where
we
we
can
can
do
do
all
all
kinds
kinds
of
of
crazy
crazy
things,
things
like
like
reference
reference
variables
variables
that
that
don't
don't
exist
exist
or
or
work
work
with
with
objects
objects
of
of
an
an
unknown
unknown
shape.
shape
The
the
code
code
is
is
interpreted
interpreted
by
by
a
a
browser,
browser
but
but
if
if
your
your
code
code
is
is
broken,
broken
you
you
won't
won't
catch
catch
it
it
until
until
run
run
when
when
the
the
browser
browser
throws
throws
an
an
error.
error
TypeScript
typescript
prevents
prevents
errors
errors
like
like
this
this
from
from
ever
ever
happening
happening
by
by
extending
extending
JavaScript
javascript
with
with
types.
types
The
the
language
language
is
is
a
a
strict
strict
superset
superset
of
of
script,
script
which
which
means
means
when
when
you
you
open
open
up
up
a
a
TS
ts
file,
file
you
you
can
can
write
write
plain
plain
JavaScript
javascript
with
with
all
all
of
of
its
its
extra
extra
features
features
being
being
completely
completely
optional.
optional
But
but
notice
notice
in
in
the
the
code
code
here
here
how
how
the
the
IDE
ide
is
is
providing
providing
feedback
feedback
about
about
using
using
a
a
variable
variable
that
that
doesn't
doesn't
exist.
exist
Instead
instead
of
of
fixing
fixing
this
this
issue
issue
weeks
weeks
later
later
in
in
a
a
stack
stack
trace
trace
after
after
the
the
company
company
loss
loss
1,000,000
1,000,000
of
of
dollars.
dollars
We
we
can
can
fix
fix
it
it
right
right
here,
here
right
right
now.
now
The
the
reason
reason
we
we
get
get
this
this
instant
instant
feedback
feedback
is
is
because
because
TypeScript
typescript
behaves
behaves
like
like
a
a
compiled
compiled
language,
language
where
where
JavaScript
javascript
is
is
the
the
compilation
compilation
target.
target
You
you
can
can
run
run
the
the
TypeScript
typescript
compiler
compiler
using
using
the
the
tsc
tsc
command.
command
It
it
will
will
take
take
the
the
TS
ts
file
file
and
and
transpile
transpile
it
it
into
into
vanilla
vanilla
JavaScript.
javascript
And
and
you
you
can
can
choose
choose
any
any
flavor
flavor
of
of
JavaScript
javascript
you
you
want
want
if
if
you
you
need
need
to
to
target
target
ancient
ancient
browsers.
browsers
And
and
that
that
means
means
you
you
can
can
use
use
the
the
latest
latest
and
and
greatest
greatest
syntax
syntax
features
features
of
of
JavaScript
javascript
without
without
having
having
to
to
worry
worry
if
if
They'll
they'll
be
be
supported
supported
in
in
an
an
older
older
environment.
environment
Your
your
TypeScript
typescript
project
project
will
will
likely
likely
have
have
a
a
tsconfig
tsconfig
file,
file
which
which
provides
provides
an
an
infinite
infinite
number
number
of
of
ways
ways
to
to
customize
customize
the
the
behavior
behavior
of
of
the
the
compiler.
compiler
But
but
the
the
primary
primary
goal
goal
of
of
TypeScript
typescript
is
is
to
to
enable
enable
static
static
typing.
typing
One
one
way
way
it
it
achieves
achieves
that
that
is
is
by
by
allowing
allowing
you
you
to
to
annotate
annotate
your
your
code
code
with
with
types.
types
We
we
can
can
strongly
strongly
type
type
a
a
variable
variable
using
using
a
a
colon
colon
followed
followed
by
by
its
its
type,
type
like
like
a
a
string,
string
Boolean,
boolean
or
or
number.
number
That's
that's
known
known
as
as
an
an
explicit
explicit
type.
type
If
if
we
we
then
then
try
try
to
to
assign
assign
its
its
value
value
as
as
the
the
wrong
wrong
type,
type
we
we
get
get
an
an
error.
error
Alternatively,
alternatively
if
if
we
we
set
set
an
an
initial
initial
value,
value
it
it
will
will
implicitly
implicitly
infer
infer
the
the
type.
type
However,
however
there
there
may
may
be
be
cases
cases
where
where
you
you
want
want
to
to
opt
opt
out
out
of
of
this
this
behavior,
behavior
in
in
which
which
case,
case
you
you
can
can
annotate
annotate
with
with
the
the
any
any
type.
type
That
that
allows
allows
you
you
to
to
loosely
loosely
type
type
or
or
opt
opt
out
out
of
of
type
type
checking.
checking
When
when
working
working
with
with
an
an
array,
array
use
use
brackets
brackets
to
to
strongly
strongly
type
type
a
a
list.
list
In
in
addition,
addition
you
you
can
can
define
define
your
your
own
own
custom
custom
types
types
and
and
interfaces,
interfaces
which
which
is
is
especially
especially
powerful
powerful
when
when
working
working
with
with
objects.
objects
The
the
car
car
interface
interface
here
here
defines
defines
various
various
types
types
of
of
the
the
properties
properties
on
on
an
an
object.
object
We
we
can
can
then
then
apply
apply
the
the
interface
interface
to
to
a
a
plain
plain
JavaScript
javascript
Object.
object
The
the
beauty
beauty
of
of
having
having
strongly
strongly
typed
typed
code
code
is
is
that
that
we
we
get
get
autocomplete
autocomplete
everywhere
everywhere
in
in
our
our
IDE.
ide
We
we
don't
don't
have
have
to
to
jump
jump
back
back
and
and
forth
forth
to
to
documentation
documentation
or
or
dig
dig
through
through
stack
stack
traces
traces
to
to
figure
figure
out
out
wire
wire
code's
code's
not
not
working.
working
If
if
you
you
like
like
TypeScript
typescript
as
as
much
much
as
as
I
i
do,
do
consider
consider
becoming
becoming
a
a
pro
pro
member
member
at
at
FireShip
fireship
IO.
io
For
for
the
the
next
next
few
few
days,
days
everything
everything
will
will
be
be
40%
40%
off,
off
including
including
lifetime
lifetime
memberships.
memberships
Thanks
thanks
for
for
watching,
watching
and
and
I
i
will
will
see
see
you
you
in
in
the
the
next
next
one.
one
success
The speaker explains that TypeScript is a dynamic language where rules are defined by the browser and cannot be fixed. TypeScript prevents errors and allows for customization through variables and interfaces. The speaker also suggests becoming a pro member at Fire Leone IO and mentions a discount for lifetime memberships.
TypeScript in 100 Seconds
TypeScript. Validate your JavaScript ahead of time with static type checking. JavaScript is a dynamic language where we can do all kinds of crazy things, like reference variables that don't exist or work with objects of an unknown shape. The code is interpreted by a browser, but if your code is broken, you won't catch it until run when the browser throws an error. TypeScript prevents errors like this from ever happening by extending JavaScript with types. The language is a strict superset of script, which means when you open up a TS file, you can write plain JavaScript with all of its extra features being completely optional. But notice in the code here how the IDE is providing feedback about using a variable that doesn't exist. Instead of fixing this issue weeks later in a stack trace after the company loss 1,000,000 of dollars. We can fix it right here, right now. The reason we get this instant feedback is because TypeScript behaves like a compiled language, where JavaScript is the compilation target. You can run the TypeScript compiler using the tsc command. It will take the TS file and transpile it into vanilla JavaScript. And you can choose any flavor of JavaScript you want if you need to target ancient browsers. And that means you can use the latest and greatest syntax features of JavaScript without having to worry if They'll be supported in an older environment. Your TypeScript project will likely have a tsconfig file, which provides an infinite number of ways to customize the behavior of the compiler. But the primary goal of TypeScript is to enable static typing. One way it achieves that is by allowing you to annotate your code with types. We can strongly type a variable using a colon followed by its type, like a string, Boolean, or number. That's known as an explicit type. If we then try to assign its value as the wrong type, we get an error. Alternatively, if we set an initial value, it will implicitly infer the type. However, there may be cases where you want to opt out of this behavior, in which case, you can annotate with the any type. That allows you to loosely type or opt out of type checking. When working with an array, use brackets to strongly type a list. In addition, you can define your own custom types and interfaces, which is especially powerful when working with objects. The car interface here defines various types of the properties on an object. We can then apply the interface to a plain JavaScript Object. The beauty of having strongly typed code is that we get autocomplete everywhere in our IDE. We don't have to jump back and forth to documentation or dig through stack traces to figure out wire code's not working. If you like TypeScript as much as I do, consider becoming a pro member at FireShip IO. For the next few days, everything will be 40% off, including lifetime memberships. Thanks for watching, and I will see you in the next one.
The speaker explains that TypeScript is a dynamic language where rules are defined by the browser and cannot be fixed. TypeScript prevents errors and allows for customization through variables and interfaces. The speaker also suggests becoming a pro member at Fire Leone IO and mentions a discount for lifetime memberships.