Menu

keywords-typealias

Will Pittenger

As described in [Type aliases], a typealias is a way to make a type name easier to use. This is especially important with generics as you might end up with this big long type descriptor that you would have to place all over your code. A typealias is also the only way to specify a type descriptor with multiple levels of explicit ref usage. The const and readonly keywords can also be embedded into the typealias declaration. However, if you use readonly on one level, you can't use const on the next. You are permitted to declare a typealias based on another typealias. Type aliases are declared just like a var, but aren't allowed a value. Type aliases can be nested inside normal types. Access them the same way you would any other nested type. Such nested type aliases must have an access qualifier applied to them. Type aliases can be directly in a namespace or global—even in SASIL. Type aliases in a namespace must also have an access qualifier applied to them.

\typealias\ /TypeDescriptor/ /identifier/

For more on what /TypeDescriptor/ can be, see Type descriptors.


Related

Wiki: By value versus by reference
Wiki: Keywords
Wiki: Type aliases
Wiki: keywords-const
Wiki: keywords-readonly
Wiki: keywords-ref
Wiki: keywords-volatile
Wiki: operators-braces
Wiki: operators-can-be-null