Skip to content

Commit 965c46b

Browse files
committed
more fixes for #14962
1 parent 5b8a93a commit 965c46b

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

test/types/connection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, Model, connection, HydratedDocument, Query } from 'mongoose';
1+
import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, Model, connection, HydratedDocument, Query, model } from 'mongoose';
22
import * as mongodb from 'mongodb';
33
import { expectAssignable, expectError, expectType } from 'tsd';
44
import { AutoTypedSchemaType, autoTypedSchema } from './schema.test';

types/connection.d.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ declare module 'mongoose' {
175175
*/
176176
readonly models: Readonly<{ [index: string]: Model<any> }>;
177177

178-
/** Defines or retrieves a model. */
179178
model<TSchema extends Schema = any>(
180179
name: string,
181180
schema?: TSchema,
@@ -185,20 +184,24 @@ declare module 'mongoose' {
185184
InferSchemaType<TSchema>,
186185
ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
187186
ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
188-
{},
187+
ObtainSchemaGeneric<TSchema, 'TVirtuals'>,
189188
HydratedDocument<
190189
InferSchemaType<TSchema>,
191-
ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
192-
ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>
190+
ObtainSchemaGeneric<TSchema, 'TVirtuals'> & ObtainSchemaGeneric<TSchema, 'TInstanceMethods'>,
191+
ObtainSchemaGeneric<TSchema, 'TQueryHelpers'>,
192+
ObtainSchemaGeneric<TSchema, 'TVirtuals'>
193193
>,
194-
TSchema> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
194+
TSchema
195+
> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
196+
197+
model<T>(name: string, schema?: Schema<any, T, any, any>, collection?: string, options?: CompileModelOptions): Model<T>;
198+
195199
model<T, U, TQueryHelpers = {}>(
196200
name: string,
197-
schema?: Schema<any, T, any, any, TQueryHelpers, any, any, any>,
201+
schema?: Schema<any, T, U, any, TQueryHelpers, any, any, any>,
198202
collection?: string,
199203
options?: CompileModelOptions
200204
): U;
201-
model<T>(name: string, schema?: Schema<any, T, any, any>, collection?: string, options?: CompileModelOptions): Model<T>;
202205

203206
/** Returns an array of model names created on this connection. */
204207
modelNames(): Array<string>;

types/inferschematype.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type IsPathDefaultUndefined<PathType> = PathType extends { default: undefined }
108108
* @param {TypeKey} TypeKey A generic of literal string type."Refers to the property used for path type definition".
109109
*/
110110
type IsPathRequired<P, TypeKey extends string = DefaultTypeKey> =
111-
P extends { required: true | [true, string | undefined] | { isRequired: true } } | ArrayConstructor | any[]
111+
P extends { required: true | (string | boolean)[] | { isRequired: true } } | ArrayConstructor | any[]
112112
? true
113113
: P extends { required: boolean }
114114
? P extends { required: false }

0 commit comments

Comments
 (0)