-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types: add overwriteMiddlewareResult and skipMiddlewareFunction to types #14328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK, but why are the classes necessary?
For the return signature of |
@hasezoey what do you think? |
i think i understand what the runtime does, but i am not quite sure how the types are supposed to work (especially the classes) maybe something other than classes would be more correct like |
My understanding: if Also, as best I can tell, since these classes aren't exported, there's no way for a user to accidentally try to instantiate them in TypeScript right? |
they are exported (see import * as mongoose from 'mongoose'; // mongoose@8.1.0 (pr #14328)
const cl = new mongoose.SkipWrappedFunction(); when removing the Property 'SkipWrappedFunction' does not exist on type 'typeof import("mongoose")'.ts(2339) Note that i only just discovered that they have
i think so too, though i am not fully sure |
Would you be ok with it if we removed the Another option: we add these classes to Kareem's TypeScript types. That would be the more technically correct way to do it, the current approach in this PR is a bit of a hack. |
i think so, this would mean that the class wouldnt be able to be
it would be more correct, but does kareem even have typescript types yet? |
Nope Kareem doesn't have types yet. This may be a forcing function for that. |
@hasezoey what do you think of this PR now with mongoosejs/kareem#37? I added Kareem types. Right now ts-benchmark is failing, so I need to debug why the perf is degrading, but what do you think of the general idea? |
i think it is now more correct (but would have worked before). the kareem PR has some work likely to-do before being merged, which also means this PR should not be merged before then.
i dont know why the perf is degrading, but for the other error, i think it does not like that there is a
maybe like i suggested in mongoosejs/kareem#37 (comment) the whole things needs to be wrapped in a |
…Script benchmark perf
will likely not re-review until the kareem dependency is a normal version again, or is there something else to test? |
@hasezoey not necessary to re-review, I'll merge this into 8.3. |
Fix #14289
Summary
Looks like there's no way to use
overwriteMiddlewareResult()
andskipMiddlewareFunction()
in TypeScript currently. This PR adds that, albeit with a couple of fake classes.Examples