Maximilian: Now, as shown in that previous lecture,
you can rely on type inference when working with arrays
and array types.
But you can of course, also explicitly set these types.
For example, if you have a new variable users,
which initially has no value.
In that case, you might wanna assign a type
to get that TypeScript support.
Now, if that were a single string,
we could set this to string.
But if it's an array of strings
as you saw in the previous lecture,
you should instead set it to this type here.
That's Typescript's way of describing an array of strings.
So the type of value that will be stored
in the user's variable is an array full of string values.
Now, what if we wanna accept either strings
or numbers in that array?
Let's say users could either be the usernames
or also their IDs.
Well, that's no problem.
You can make this type slightly more complex
by wrapping string in brackets
and turning it into a union type like this.
Now, you are telling TypeScript
that the user's variable will store a value of type array,
and that array internally will hold values
that are either a string or a number.
Therefore, we could store this kind of array in users
or override it with this kind of array
or with this one here.
All that works because of this type assignment.
So as you can see, array types, in the end,
are really just enhancements of these standards types,
which you saw before.
You define that you have an array
and you define what's inside of this array.