ts and assignPropValue

This commit is contained in:
mol
2024-06-11 08:58:38 +08:00
parent bca43ff93c
commit 72a1743d75
6 changed files with 49 additions and 11 deletions

16
src/ts/handle.ts Normal file
View File

@ -0,0 +1,16 @@
// keyof 操作符遍历对象的key
export type keys<T> = keyof T;
const a = { a: 1, b: 2, c: 3 };
// typeof 提取类型
export type Ta = keys<typeof a>;
// Omit 去除某一项
export type Ta2 = Omit<typeof a, "b">;
// Pick 选择某一项
export type Ta3 = Pick<typeof a, "c">;
// & 添加
export type Ta4 = Ta3 & { d: string };