Skip to content

Commit

Permalink
fix(types): avoid adding non-existent properties from model construct…
Browse files Browse the repository at this point in the history
…or for typegoose

Fix #11960
  • Loading branch information
vkarpov15 committed Jun 24, 2022
1 parent 73156b5 commit 5409717
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions test/types/document.test.ts
Expand Up @@ -192,8 +192,6 @@ function autoTypedDocument() {
expectType<AutoTypedSchemaType['schema']['userName']>(AutoTypeModelInstance.userName);
expectType<AutoTypedSchemaType['schema']['favoritDrink']>(AutoTypeModelInstance.favoritDrink);
expectType<AutoTypedSchemaType['schema']['favoritColorMode']>(AutoTypeModelInstance.favoritColorMode);
expectType<number>(AutoTypeModelInstance.unExistProperty);
expectType<number>(AutoTypeModelInstance.description);

// Document-Methods-tests
expectType<ReturnType<AutoTypedSchemaType['methods']['instanceFn']>>(new AutoTypedModel().instanceFn());
Expand Down
2 changes: 1 addition & 1 deletion types/models.d.ts
Expand Up @@ -119,7 +119,7 @@ declare module 'mongoose' {
AcceptsDiscriminator,
IndexManager,
SessionStarter {
new <DocType = T>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<MergeType<T, DocType>, TMethodsAndOverrides, TVirtuals> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;
new <DocType = T>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<T, TMethodsAndOverrides, TVirtuals> & ObtainSchemaGeneric<TSchema, 'TStaticMethods'>;

aggregate<R = any>(pipeline?: PipelineStage[], options?: mongodb.AggregateOptions, callback?: Callback<R[]>): Aggregate<Array<R>>;
aggregate<R = any>(pipeline: PipelineStage[], callback?: Callback<R[]>): Aggregate<Array<R>>;
Expand Down

0 comments on commit 5409717

Please sign in to comment.