类型体操

How to type a non-empty array in typescript?

typescript
1
export type NonEmptyArray<T> = [T, ...T[]];

How to type a array which shouldn't contain nullable item?

typescript
1
export type NonNullableElement<T> = T extends (infer U)[] ? NonNullable<U>[] : T;