TypeScript
Generics
example for generic array function
function loggingIdentity<T>(arg: T[]): T[] {
console.log(arg.length);
return arg;
}
// explicitly set T if type cannot be interfered (e.g. via argument)
let output = dosomething<string>("myString");
Enums and type aliases
example numeric enum start starts with 1 and automincrements from there
enum AuthLevel {
Secure = 1,
Relaxed,
Public,
}
type alias see see tutorial
export declare type EntityTypePath = 'places' | 'notes' | 'dishes';
function doAlign(path: EntityTypePath):void{
console.log(path);
}