Utility Types
The package includes a collection of useful TypeScript types that can help with common use-cases in TypeScript projects.
Type Aliases
Constructor()
Constructor<
T> = (…args) =>T
Defined in: index.ts:24
A type that represents a class constructor.
Type Parameters
T
T = any
The class.
Parameters
args
…any[]
Returns
T
Example
class MyClass {}type MyConstructor = Constructor<MyClass>;OmitFunctionMembers
OmitFunctionMembers<
T> ={ [K in keyof T as T[K] extends Function ? never : K]: T[K] }
Defined in: index.ts:36
Creates a subsidiary type that omits all function members from a given type.
Type Parameters
T
T
The type to omit function members from.
Example
interface MyInterface { foo: string; bar(): void;}type MyOmitted = OmitFunctionMembers<MyInterface>; // { foo: string; }OptionalProperties
OptionalProperties<
T> ={ [K in keyof T as {} extends { [P in K]: T[K] } ? K : never]: T[K] }
Defined in: index.ts:12
A type that extracts the optional properties from another type.
Type Parameters
T
T
The type to extract optional properties from.
Example
interface MyInterface { foo: string; bar?: string;}type MyOptional = OptionalProperties<MyInterface>; // { bar?: string; }