/** * Exclude from T those types that are assignable to U. * typescript/lib/lib.es5.d.ts */typeExclude<T, U>=TextendsU?never : T;
1.
6. Extract<Type, Union>
通过从 Type 中提取所有可分配给 Union 的联合成员来构造一个类型。
/** * Extract from T those types that are assignable to U. * typescript/lib/lib.es5.d.ts */typeExtract<T, U>=TextendsU?T : never;
1.
7. Pick<Type, Keys>
通过从 Type 中选择一组属性 Keys(字符串文字或字符串文字的联合)来构造一个类型。
/** * From T, pick a set of properties whose keys are in the union K. * typescript/lib/lib.es5.d.ts */typePick<T, KextendskeyofT>= { [PinK]: T[P];};
1.
8.Omit<Type, Keys>
通过从 Type 中选择所有属性然后删除 Keys(字符串文字或字符串文字的联合)来构造一个类型。
/** * Construct a type with the properties of T except for those * in type K. * typescript/lib/lib.es5.d.ts */typeOmit<T, Kextendskeyofany>=Pick<T, Exclude<keyofT, K>>;
1.
9. NonNullable<Type>
通过从 Type 中排除 null 和 undefined 来构造一个类型。
/** * Exclude null and undefined from T. * typescript/lib/lib.es5.d.ts */typeNonNullable<T>=Textendsnull|undefined?never : T;
1.
10. Parameters<Type>
从函数类型 Type 的参数中使用的类型构造元组类型。
/** * Obtain the parameters of a function type in a tuple. * typescript/lib/lib.es5.d.ts */typeParameters<Textends (...args: any) =>any>=Textends (...args: inferP) =>any?P : never;
1.
11. ReturnType<Type>
构造一个由函数 Type 的返回类型组成的类型。
/** * Obtain the return type of a function type. * typescript/lib/lib.es5.d.ts */typeReturnType<Textends (...args: any) =>any>=Textends (...args: any) =>inferR?R : any;