This commit is contained in:
mol
2024-06-07 09:45:56 +08:00
parent 6f8082ff50
commit bca43ff93c

9
src/ts/type.ts Normal file
View File

@ -0,0 +1,9 @@
// ValueOf 将对象类型转换成值的枚举值
// keyof 操作符遍历对象的key
export type ValueOf<T> = T[keyof T];
export const enum1 = {
AAA: "aaa",
BBB: "bbb",
} as const;
// typeof 提取类型
export type TEnum1 = ValueOf<typeof enum1>;