diff --git a/types/common.d.ts b/types/common.d.ts index 5831b144..912076c9 100644 --- a/types/common.d.ts +++ b/types/common.d.ts @@ -18,7 +18,7 @@ export type Options = AnyObject<any>; /** * Type alias for Node.js callback functions */ -export type Callback<T = any> = (err?: Error | null, result?: T) => void; +export type Callback<T = any> = (err?: any | null, result?: T) => void; /** * Return export type for promisified Node.js async methods. diff --git a/types/model.d.ts b/types/model.d.ts index 90af3816..6e525071 100644 --- a/types/model.d.ts +++ b/types/model.d.ts @@ -242,8 +242,14 @@ export declare class ModelBuilder extends EventEmitter { ): ModelBaseClass; } +/** + * An extension of the built-in Partial<T> type which allows partial values + * in deeply nested properties too. + */ +export type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; }; + /** * Union export type for model instance or plain object representing the model * instance */ -export type ModelData<T extends ModelBase = ModelBase> = T | Partial<T>; +export type ModelData<T extends ModelBase = ModelBase> = T | DeepPartial<T>;