Union types
The structural union type, written (t1,t2,tN), consists of two or more member types, containing all possible values of the member types.
(decimal,string)
Restrictions
- Unions contain two or more members.
Default value
The default value of an union type is determined as follows:
- If it contains
void, thenundefined. - If it contains
null, thennull. - No default value.
Nullability
The following shorthands are available for nullability:
- “
t?” is equivalent to(t,null). - “
t!” removesnulland/orvoidfromt.