[Typescript] 136. Medium - NonEmptyArray
type NonEmptyArray<T> = [T, ...Array<T>];
export const makeEnum = (values: NonEmptyArray<string>) => {};
makeEnum(["a"]);
makeEnum(["a", "b", "c"]);
// @ts-expect-error
makeEnum([]);
The idea is that T
should be an array type with at least one value.