Aliases are interchangeable with underlying types
UserId and int32 from the above are fully equivalent:
id + 1is okay, will beintsomeF(id)is okay ifsomeFacceptsint32orint- methods for
int32can be called havingUserIdand vice versa (and forintalso, becauseint32is assignable toint) - a union
UserId | int32makes no sense, it is simplyint32
int32, but it becomes a distinct type with its own methods and semantics.
Two equal aliases are considered different
If two aliases share the same underlying type,intN types: int32 is assignable to int and back, int64 also, but assigning int32 to int64 is something strange.