Skip to content

Commit

Permalink
Update statics.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 3, 2023
1 parent cdfae32 commit ab7ea18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/typescript/statics.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ doc.updateName('foo');
UserModel.createWithName('bar');
```

### With Generics
## With Generics

While we recommend using Mongoose's automatic type inference where possible, you may need to override method and static types using generic parameters.
We recommend using Mongoose's automatic type inference where possible, but you can use `Schema` and `Model` generics to set up type inference for your statics and methods.
Mongoose [models](../models.html) do **not** have an explicit generic parameter for [statics](guide.html#statics).
If your model has statics, we recommend creating an interface that [extends](https://www.typescriptlang.org/docs/handbook/interfaces.html) Mongoose's `Model` interface as shown below.

Expand Down Expand Up @@ -79,4 +79,4 @@ const User = model('User', schema);
const doc = new User({ name: 'test' });
// Compiles correctly
doc.updateName('foo');
```
```

0 comments on commit ab7ea18

Please sign in to comment.