×

We use cookies to help make LingQ better. By visiting the site, you agree to our cookie policy.


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 en 100 segundos|| TypeScript في 100 ثانية TypeScript in 100 Sekunden TypeScript in 100 Seconds TypeScript en 100 segundos TypeScript en 100 secondes Dattiloscritto in 100 secondi 100秒でわかるTypeScript TypeScript w 100 sekund TypeScript em 100 segundos TypeScript за 100 секунд 100 Saniyede TypeScript 100 秒内完成 TypeScript

[Music] Музыка [Musica]

typescript validate your javascript |||typescript |||validar tu javascript |перевірити|| المطبوع عليه التحقق من صحة جافا سكريبت الخاص بك dattiloscritto convalida il tuo javascript typescript validar o seu javascript

ahead of time with static type checking ||время|||| ||||||type validation заздалегід|||||| في وقت مبكر مع فحص نوع ثابت 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 ||||executed|| ||||інтерпретується|| شكل الكود يتم تفسيره بواسطة أ 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 |||tiempo de ejecución||| قبض عليه حتى وقت التشغيل عندما المتصفح 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 ||происходить|| ||||prolonging من أي وقت مضى عن طريق التوسع dal mai accadere estendendo

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

the language is a strict superset of ||||fully inclusive of|includes entirely| |||||superconjunto estricto de| اللغة هي مجموعة شاملة صارمة من 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 |archivo ts|||||| 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 ||call sequence||||| 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 ||||JavaScript processing ||||компіляція ||||compilación de JavaScript dove javascript è la compilazione

target you can run the typescript target puoi eseguire il dattiloscritto

compiler Compilador compilatore

using the tsc command it will take the ||usando tsc|||||

ts file and transpile it into vanilla |||Convert TypeScript||| |||транспілю|||чистий JavaScript |||transpilar|||vainilla pura ts file e traspilalo in vaniglia

javascript

and you can choose any flavor of |||||any type of|

javascript you want if you need to

target ancient browsers |outdated| ||Navegadores antiguos objetivo 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 ||||archivo de configuración|

which provides an infinite number of

ways to customize the behavior of the ||personalizar el comportamiento||||

compiler

but the primary goal of typescript is to

enable static typing

one way it achieves that is by allowing |||logra||||

you to annotate your code with types ||Label|||| ||anotar||||

we can strongly type a variable using a

colon followed by its type like a string Dos puntos|||||||

boolean or number boolean o número||

that's known as an explicit type if we ||||clearly defined type|||

then try to assign its value as the

wrong type we get an error

alternatively if we set an initial value alternativamente si establecemos||||||

it will implicitly infer the type |||deduce|| |||inferir implícitamente||

however there may be cases where you

want to opt out of this behavior ||choose to leave||||

in which case you can annotate with the

any type that allows you to loosely type ||||||flexibly typed| ||||||libremente|

or opt out of type checking when working

with an array

use brackets to strongly type a list in |corchetes||||||

addition you can define your own custom ||||||personalizado

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 ||||||superficie simple

javascript object

the beauty of having strongly typed code |||||tipado fuerte|

is that we get autocomplete everywhere ||||autocompletar|

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 ||||||del código|

working

if you like typescript as much as i do

consider becoming a pro member at

fireship io for the next few days fireship.io website|||||| fireship io||||||

everything will be 40 off including

lifetime memberships thanks for watching |membresías de por vida|||

and i will see you in the next one