2. What is
• ”TypeScript is an open-source programming language developed and
maintained by Microsoft. It is a strict
syntactical superset of JavaScript, and adds optional static typing to
the language.” [1]
5. Type guards
• Let’s you specify a function that returns true/false based on whether
the passed parameter is of a specific type
6. Discriminated union
• Sort of does the same thing as above but less boilerplate
• Compile knows which type object is (out of a set of types) based on a
common field
7. keyof T operator
• Returns a set of permitted property names for object T
• E.g. keyof Person ”firstName” | ”lastName”
8. Pick<T, K>, Exclude<T, K>, OmitType<T1,T2>,
...
• Useful if you need to add or remove missing fields from a type
• Pick and Exclude and others are provided by the language
• OmitType requires a custom type
• export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
• export type OmitType<T1 extends T2, T2> = Pick<T1, Exclude<keyof
T1, keyof T2>>;