- Pick
type MyPick<T, K extends keyof T> = {
[U in K]: T[U];
}- Readonly
type MyReadonly<T> = {
readonly [U in keyof T]: T[U];
}- First of Array
type First<T extends any[]> = T['length'] extends 0 ? never : T[0]; Perhaps you don't know you can get length of an array type.
- Lengh of Tuple
type Length<T extends readonly unknown[]> = T['length'];- Exclude
type MyExclude<T, U> = T extends U ? never : T;Actually, it runs for each sub type of a union type.
- Awaited
type Awaited<T extends Promise<any>> = T extends Promise<infer U> ? U : never;- Contact
type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U];