Open1
Type-challenges
Easy
Pick
type MyPick<T,K extends keyof T> = { [key in K]:T[key] }
ReadOnly
type MyReadonly<T> = { readonly [key in keyof T]: T[key] }
Tuple to Object
type TupleToObject<T extends readonly any[]> = { [value in T[number]]: value }
First of array
type First<T extends any[]> = T extends [] ? never : T[0]
空配列はneverと同義。
Length of Tuple
type Length<T extends readonly any[]> = T["length"]