Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.