This is the fourth day of my participation in the November Gwen Challenge. See details: The last Gwen Challenge 2021.
Object types
Common object implementation
There are three forms
1. Anonymous objects, that is, you can define an object type directly after a variable to describe the variable
2, interface named object, can declare an interface type of a name, to describe the object
You can declare a type of type to name an object
The property modifier && optional property
Attributes can be aliased and then described using aliases when used
A quick description of the optional property is “?” Indicates that this parameter is optional
Read-only property
Readonly is a proxy for read-only properties
The index sign
Index signatures are described with “[]”
Extension type
We can use interfaces to customize the description of object types.
Cross type
Types can also be interleaved between types
The generic
Stereotypes are one of Typescript’s more advanced and relatively flexible syntax, and can also be represented by the T abbreviation. Refers to a type as an incoming type. A common use is when a function’s input parameter is used, and when teturn is also referred to as T, that is, the input participates in the return value of the same type.
A tuple type
Let arr5: [string, number, Boolean]; let arr5: [string, number, Boolean];