Based on Sitepen’s TypeScript Cheat Sheet
| 1 | 2 |
|---|---|
Build script language |
|
Any type (explicitly untyped) |
|
String |
|
Number |
|
Boolean |
|
Named types (interface, class, enum) |
|
Interface |
|
Class |
class Child extends Parent implements IChild, IOtherChild {
property:Type;
defaultProperty:Type = 'default value';
private _privateProperty:Type;
static staticProperty:Type;
constructor(arg1:Type) {
super(arg1);
}
private _privateMethod():Type {}
methodProperty:(arg1:Type) => ReturnType;
overloadedMethod(arg1:Type):ReturnType;
overloadedMethod(arg1:OtherType):ReturnType;
overloadedMethod(arg1:CommonT):CommonReturnT {}
static staticMethod():ReturnType {}
subclassedMethod(arg1:Type):ReturnType {
super.subclassedMethod(arg1);
}
} |
Enum |
|
Object type literals |
|
Object with implicit Any properties |
|
Object with optional property |
|
Hash map |
|
Arrays |
|
Array of strings |
|
Array of functions that return strings |
|
Functions |
|
Function |
|
Constructor |
|
Function type with optional param |
|
Function type with rest param |
|
Function type with static property |
|
Default argument |
|
Arrow function |
|
Generics |
|
Function using type parameters |
|
Interface with multiple types |
|
Constrained type parameter |
|
Other |
|
Type of a variable |
|