HookNextFunction missing from local types?
See original GitHub issueWe were recently attempting to update to mongoose 5.11.3 and ran into this compilation error:
src/model/document/ModelRef.ts:4:25 - error TS2305: Module '"mongoose"' has no exported member 'HookNextFunction'.
4 import { Schema, Model, HookNextFunction } from 'mongoose'
~~~~~~~~~~~~~~~~
This is currently defined in the @types/mongoose but is not defined in the mongoose types. Is this intended behavior (so we need to now import these from another module) or unintentional? If it’s unintentional, I think some of the other Hook*** are missing as well.
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
"this" and "next" in mongoose middleware with TS not working
I am trying to make middleware work with Typescript, but both this and next in pre and post are not working correctly, I...
Read more >Migrating to Mongoose 6
The following legacy types have been removed: ModelUpdateOptions; DocumentQuery; HookSyncCallback; HookAsyncCallback; HookErrorCallback; HookNextFunction ...
Read more >Working with Mongoose in TypeScript - The Code Barbarian
Hello, World. First, install the necessary packages: npm install mongoose typescript @types/mongoose. To get started with Mongoose, you should ...
Read more >How to Migrate Mongoose from v5.x to v6.x - Morioh
When connected to a replica set, connections now emit 'disconnected' when connection to the primary is lost. In Mongoose 5, connections only ...
Read more >Module '"mongoose"' has no exported member ... - YouTube
In this video, we fix an error related to DocumentDefinition and update service inputs so they do not need to omit values.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are hitting a few other issues but it’s in some of the generic stuff so I need to look more closely at that to see if it’s something we were relying upon which wasn’t actually true or some discrepancy between the two type systems. If I narrow it down and it’s not us, I’ll open separate defects for that.
I’ve noticed you’ve been full out at trying to get all of the issues reported with the types fixed quickly and have been very grateful for your work on that!
I’m assuming you are using 6.x+ now? It was added back in the 5.x stream after this issue was closed but was removed from the 6.x code base per the migration document at https://mongoosejs.com/docs/migrating_to_6.html
We’ve worked around it by just defining it ourselves going forward like so: