首页 > 其他分享 >[Typescript] 136. Medium - NonEmptyArray

[Typescript] 136. Medium - NonEmptyArray

时间:2022-12-11 22:37:31浏览次数:58  
标签:Typescript makeEnum NonEmptyArray Medium 136 type

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 Tshould be an array type with at least one value.

标签:Typescript,makeEnum,NonEmptyArray,Medium,136,type
From: https://www.cnblogs.com/Answer1215/p/16974714.html

相关文章