interface
partial
interface a {name:string;age:number}type b = Partial<a>b为type b = {name?: string | undefined;age?: number | undefined;}
pick
interface a {name?:string;age?:number;id:number;}type c = Pick<a,'name'>//type c = {name?: string | undefined;}
omit
interface a {name?:string;age?:number;id:number;}type c = Omit<a,'name'>//type c = {age?: number | undefined;id: number;}
record
定义对象的键值对类型
interface PageInfo {title: string;}type Page = "home" | "about" | "contact";const nav: Record<Page, PageInfo> = {about: { title: "about" },contact: { title: "contact" },home: { title: "home" },};
type
Exclude
type a = Number | String | Booleantype b = Exclude<a,Number>b:type b = String | Boolean
Extract
NonNullable
ReturnType
InstanceType
