A typescript guide,
- learn the primitive types ... number, string, etc. https://www.typescriptlang.org/docs/handbook/2/everyday-types.html
- Unions and Intersections https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html
- Pick, Omit, Partial https://dev.to/glebirovich/5-typescript-utility-types-that-will-make-your-life-easier-i44
- Typescript how to extract nested type:
https://stackoverflow.com/questions/56779149/typescript-how-to-extract-nested-type - Learn
?
- also?
is not the same as| undefined
- but don't focus on this too much. - The "Top Level Type" is the most important type.
Try to use the type the library gives you for free and get everything inferred from that point onward.
If you get the Top Level Type wrong you will find that you are typing everything at a micro level and overtyping.
everything else will probably be too much early on.
Also generic types can be useful for functions and libraries that others consume; This is the simplest example of a generic I can think of:
export const func = <T>(value: T): T => {
return value;
}