总字数 368
预计阅读时间 1 分钟
TypeScript当中有一些内置的类型,适用于编译过程
Partial<Type>
将Type的所有属性都设置为可选的,表示输入类型的所有子类型
1 | interface Person { |
Readonly<Type>
将Type的所有属性都设置为readonly
1 | interface Person { |
Record<Keys, Type>
用来将某个类型的属性映射到另一个类型上
1 | interface PageInfo { |
Pick<Type, Keys>
从类型Type中挑选部分属性Keys来构造类型
1 | interface Person { |
Omit<Type, Keys>
与Pick用法类似,作用是相反的,用于从中剔除若干个key
1 | interface Person { |