TypeScript
Function Overloading
Take a function like below… 1 2 3 4 5 6 7 8 type Combinable = string | number function add(a: Combinable, b: Combinable): Combinable { if (typeof a === …
Read →Nullish Coalescing
1 2 // say you have some var hangin' around called `name` let x: string = name ?? '(no name)' ?? is the nullish coalescing operator. It differs from …
Read →Recursive Type Aliases
In TS@4 a type can reference itself, e.g. 1 2 3 4 5 6 7 8 9 type JSONValue = | string | number | boolean | null | JSONValue[] | { [k: string]: JSONValue } …
Read →Labeled Tuple Types
1 type Address = [number, string, string, number] Say you now have a function printAddress which takes an Address type as its arg. 1 2 3 function …
Read →Variadic Tuple Types
1 type Foo<T extends any[]> = [boolean, ...T, boolean] Before TS@4.0 ...T would need to be the last element, but now we can spread the T type nested …
Read →Composite Builds
TypeScript has a way of describing a build process as multiple subpieces of a project. This saves from having to build every piece, and instead build …
Read →