×

Usamos cookies para ayudar a mejorar LingQ. Al visitar este sitio, aceptas nuestras politicas de cookie.


image

Programming, TypeScript in 100 Seconds

TypeScript in 100 Seconds

[Music]

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 runtime when the browser

rows an error

typescript prevents errors like this

from ever happening by extending

javascript with types

the language is a strict superset of

javascript 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 has

lost millions 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 ts config 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 why our 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 in 100 Seconds TypeScript في 100 ثانية TypeScript in 100 Seconds TypeScript en 100 secondes Dattiloscritto in 100 secondi TypeScript em 100 segundos TypeScript за 100 секунд 100 秒内完成 TypeScript

[Music] [Musica]

typescript validate your javascript المطبوع عليه التحقق من صحة جافا سكريبت الخاص بك dattiloscritto convalida il tuo javascript

ahead of time with static type checking في وقت مبكر مع فحص نوع ثابت in anticipo con il controllo del tipo statico

javascript is a dynamic language where جافا سكريبت هي لغة ديناميكية حيث javascript è un linguaggio dinamico in cui

we can do all kinds of crazy things يمكننا القيام بكل أنواع الأشياء المجنونة possiamo fare tutti i tipi di cose pazze

like reference variables that don't مثل المتغيرات المرجعية التي لا come le variabili di riferimento che non lo fanno

exist or work with objects of an unknown موجودة أو تعمل مع أشياء مجهولة esistere o lavorare con oggetti di uno sconosciuto

shape the code is interpreted by a شكل الكود يتم تفسيره بواسطة أ forma il codice è interpretato da a

browser المتصفح browser

but if your code is broken you won't ولكن إذا تم كسر الكود الخاص بك ، فلن تفعل ذلك ma se il tuo codice è rotto non lo farai

catch it until runtime when the browser قبض عليه حتى وقت التشغيل عندما المتصفح catturalo fino al runtime quando il browser

rows an error صفوف خطأ righe un errore

typescript prevents errors like this المطبوع عليه يمنع أخطاء مثل هذا dattiloscritto previene errori come questo

from ever happening by extending من أي وقت مضى عن طريق التوسع dal mai accadere estendendo

javascript with types جافا سكريبت بأنواعها

the language is a strict superset of اللغة هي مجموعة شاملة صارمة من la lingua è un rigoroso superset di

javascript which means when you open up جافا سكريبت وهو ما يعني عندما تفتح javascript che significa quando apri

a ts file you can write plain javascript ts يمكنك كتابة جافا سكريبت عادي un file ts puoi scrivere javascript semplice

with all of its extra features بكل ميزاته الإضافية

being completely optional but notice in كونها اختيارية تمامًا ولكن لاحظ ذلك essendo completamente facoltativo ma nota in

the code here how the ide رمز هنا كيف بيئة تطوير متكاملة il codice qui come l'ide

is providing feedback about using a يقدم ملاحظات حول استخدام ملف sta fornendo feedback sull'utilizzo di a

variable that doesn't exist متغير غير موجود

instead of fixing this issue weeks later بدلاً من إصلاح هذه المشكلة بعد أسابيع invece di risolvere questo problema settimane dopo

in a stack trace after the company has in una traccia dello stack dopo che l'azienda ha

lost millions of dollars we can fix it perso milioni di dollari possiamo aggiustarlo

right here right now proprio qui proprio ora

the reason we get this instant feedback il motivo per cui otteniamo questo feedback immediato

is because typescript behaves like a è perché il dattiloscritto si comporta come a

compiled language linguaggio compilato

where javascript is the compilation dove javascript è la compilazione

target you can run the typescript target puoi eseguire il dattiloscritto

compiler compilatore

using the tsc command it will take the

ts file and transpile it into vanilla ts file e traspilalo in vaniglia

javascript

and you can choose any flavor of

javascript you want if you need to

target ancient browsers prendere di mira i browser antichi

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 ts config 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 why our 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