All language subtitles for 008 Understanding Type Aliases_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Now the more TypeScript code you're going to

write, the higher the chances that

at some point you might be repeating some type definition.

And we're actually already doing this here.

Here, for people, I'm saying that I want an array

of this kind of object.

So that I want an array full

of objects that have this structure.

And that's the same object I have up here

for person.

The same type definition just in the non array form.

But the object type is the same.

Now you can, of course, duplicate the type definition

but it's more realistic that you wanna

avoid that duplication.

And for that, you can create a so-called type alias.

You can define your own base type

in which a more complex type definition is stored

and then use that type alias instead

of repeating the entire type definitions.

For that here, for example, before we use this object type

for the first time here, we can define such a type alias

with the type keyword.

And that's a keyword which does not

exist in standard JavaScript but

which is added by TypeScript instead.

Now, after this type keyword, you use any name

of your choice which will be your new type name.

For example, person, like this.

And then after the equal sign here

you then have a type definition

because this is a pure TypeScript feature.

This will basically be thrown out

of the window when the code is compiled to JavaScript.

So, here on the right side of the equal sign

it's not a JavaScript value, but instead a type definition.

And that could be our object type definition here

which I now store here in this person type.

And now in all those places where I used this object type

I can use my alias instead now.

And it's therefore still the same type

but I only define it once.

And then I can repeat it in all the places where I need it.

And I can still also change it like I'm doing it

down here to use it just as person like this,

or to use it as an array full of persons.

That also works.

And that's the very important feature of type aliases

which can save you a lot of typing work

and which can, therefore, make your code more concise

and easier to maintain.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.