ts and assignPropValue
This commit is contained in:
16
src/ts/handle.ts
Normal file
16
src/ts/handle.ts
Normal 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 };
|
Reference in New Issue
Block a user