Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Re: #15780

Summary

My suggested workaround for #15780 would be to use as DocStatics, but that currently fails with the following error:

Type 'DocStatics' is not assignable to type '{ [name: string]: (this: Model<IDoc, {}, {}, {}, Document<unknown, {}, IDoc, {}, {}> & IDoc & Required<{ _id: unknown; }> & { __v: number; }, any>, ...args: any[]) => any; }'. Index signature for type 'string' is missing in type 'DocStatics'.

This PR adds an override to Schema.prototype.static() to support calling static() with exactly the TStatics type

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Nov 26, 2025
@vkarpov15 vkarpov15 modified the milestones: 8.20.2, 9.0.1 Nov 26, 2025
@vkarpov15 vkarpov15 merged commit 70466d0 into master Nov 26, 2025
5 checks passed
@vkarpov15 vkarpov15 modified the milestones: 9.0.1, 8.20.2 Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Types or Types-test related issue / Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants