Awesome TypeScript
Jussi Haapanen
TampereJS meetup
11.10.2018
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]
Used by:
TypeScript features
• Type checking
• Refactoring
Type guards
• Let’s you specify a function that returns true/false based on whether
the passed parameter is of a specific type
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
keyof T operator
• Returns a set of permitted property names for object T
• E.g. keyof Person  ”firstName” | ”lastName”
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>>;
Configuration
• downLevelIteration
• Async/Await, Spread operation support for ES3
• strictNullChecks
• Makes sure you can’t mix type T, undefined or null
Questions?
References
• [1] https://en.wikipedia.org/wiki/TypeScript

Awesome typescript