类型体操
Published by powerfulyang on Jan 4, 2023
非空数组的类型,元素非空数组的类型
How to type a non-empty array in typescript?
1export type NonEmptyArray<T> = [T, ...T[]];
How to type a array which shouldn't contain nullable item?
1export type NonNullableElement<T> = T extends (infer U)[] ? NonNullable<U>[] : T;