Alias interchangeability
Aliases are interchangeable with underlying types.UserId and int32 from the above example are fully equivalent:
id + 1is valid and producesint;someF(id)is valid ifsomeFacceptsint32orint;- methods for
int32can be called onUserIdvalues and vice versa; and also forint, sinceint32is assignable toint; - a union
UserId | int32is redundant and is equivalent toint32.
int32, but it becomes a distinct type with its own methods and semantics.
Distinct alias types
Two aliases with the same underlying type are considered distinct. If two aliases share the same underlying type:intN types: int32 is assignable to int, and int64 is assignable to int, but int32 and int64 are not assignable to each other. Assignment can be done with an explicit cast. For example, b as AssetsDict.