Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 馃悰 Types of Connection.deleteModel() #11812

Merged
merged 1 commit into from May 17, 2022

Conversation

tkowpt
Copy link

@tkowpt tkowpt commented May 16, 2022

The documentation and the code of Connection.deleteModel() tells, that
it accepts a string and a RegExp. So, the types should accept a RegExp
as well.

Summary

At the moment moongoose.connection.deleteModel(/.+/) is not working in the test code in one of my typescript repositories, because of a type error. The javascript code of deleteModel tells, that a RegExp is accepted, but the current types only allow a string as parameter. My current workaround is mongoose.connection.deleteModel(<string><unknown>/.+/), what is not ideal in my opinion.

Examples

The following line should work in typescript as well:

mongoose.connection.deleteModel(/.+/)

The documentation and the code of Connection.deleteModel() tells, that
it accepts a string and a RegExp. So, the types should accept a RegExp
as well.
@Uzlopak
Copy link
Collaborator

Uzlopak commented May 16, 2022

Good Catch.

Please add a test to test/types/connection.test.ts in line 41

expectType<Connection>(conn.deleteModel(/.+/));

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks 馃憤

@vkarpov15 vkarpov15 added this to the 6.3.4 milestone May 17, 2022
@vkarpov15 vkarpov15 merged commit cea313e into Automattic:master May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants