Created
May 5, 2020 17:29
-
-
Save andreialecu/2d1f4ed3ae5db12fab4c399eddd83e40 to your computer and use it in GitHub Desktop.
typegoose patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/@typegoose/typegoose/lib/typeguards.d.ts b/node_modules/@typegoose/typegoose/lib/typeguards.d.ts | |
index 0673d2c..3b602d7 100644 | |
--- a/node_modules/@typegoose/typegoose/lib/typeguards.d.ts | |
+++ b/node_modules/@typegoose/typegoose/lib/typeguards.d.ts | |
@@ -3,19 +3,19 @@ import type { DocumentType, Ref, RefType } from './types'; | |
* Check if the given document is already populated | |
* @param doc The Ref with uncertain type | |
*/ | |
-export declare function isDocument<T, S extends RefType>(doc: Ref<T, S>): doc is DocumentType<T>; | |
+export declare function isDocument<T extends { _id: RefType }, S extends RefType>(doc: Ref<T, S>): doc is DocumentType<T>; | |
/** | |
* Check if the given array is already populated | |
* @param docs The Array of Refs with uncertain type | |
*/ | |
-export declare function isDocumentArray<T, S extends RefType>(docs: Ref<T, S>[]): docs is DocumentType<T>[]; | |
+export declare function isDocumentArray<T extends { _id: RefType }, S extends RefType>(docs: Ref<T, S>[]): docs is DocumentType<T>[]; | |
/** | |
* Check if the document is not undefined/null and is not an document | |
* @param doc The Ref with uncretain type | |
*/ | |
-export declare function isRefType<T, S extends RefType>(doc: Ref<T, S>): doc is S; | |
+export declare function isRefType<T extends { _id: RefType }, S extends RefType>(doc: Ref<T, S>): doc is S; | |
/** | |
* Check if the document is not undefined/null and is not an document | |
* @param docs The Ref with uncretain type | |
*/ | |
-export declare function isRefTypeArray<T, S extends RefType>(docs: Ref<T, S>[]): docs is S[]; | |
+export declare function isRefTypeArray<T extends { _id: RefType }, S extends RefType>(docs: Ref<T, S>[]): docs is S[]; | |
diff --git a/node_modules/@typegoose/typegoose/lib/types.d.ts b/node_modules/@typegoose/typegoose/lib/types.d.ts | |
index 2fbe794..a66b58e 100644 | |
--- a/node_modules/@typegoose/typegoose/lib/types.d.ts | |
+++ b/node_modules/@typegoose/typegoose/lib/types.d.ts | |
@@ -239,15 +239,17 @@ export interface VirtualOptions { | |
export declare type PropOptionsWithNumberValidate = PropOptions & ValidateNumberOptions; | |
export declare type PropOptionsWithStringValidate = PropOptions & TransformStringOptions & ValidateStringOptions; | |
export declare type PropOptionsWithValidate = PropOptionsWithNumberValidate | PropOptionsWithStringValidate | VirtualOptions; | |
-export declare type RefType = number | string | mongoose.Types.ObjectId | Buffer; | |
+export declare type RefType = number | string | mongoose.Types.ObjectId | Buffer | undefined; | |
export declare type RefSchemaType = typeof mongoose.Schema.Types.Number | typeof mongoose.Schema.Types.String | typeof mongoose.Schema.Types.Buffer | typeof mongoose.Schema.Types.ObjectId; | |
/** | |
* Reference another Model | |
* @public | |
*/ | |
-export declare type Ref<R, T extends RefType = R extends { | |
- _id: RefType; | |
-} ? R['_id'] : mongoose.Types.ObjectId> = R | T; | |
+export declare type Ref< | |
+ R extends { _id: RefType }, | |
+ T extends RefType = NonNullable<Pick<R, "_id">> extends { _id: RefType } ? R["_id"] : mongoose.Types.ObjectId | |
+> = R | T; | |
+ | |
/** | |
* An Function type for a function that doesn't have any arguments and doesn't return anything | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment