-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Typescript types on "this" in instance methods #13800
Comments
I made this PR to fix this: #13822 |
I think you could update your schema as follows:
This way, the typing should work just fine. You can then delete the following:
Not sure if that works but it should I think. |
Fixed by #13822 |
I'm glad to see that this was fixed, but when will this be available in an official release? What is the release schedule like? Should this be marked closed if it's still not available in an official release? |
Okay nevermind, I see that this is scheduled to release in 7.5.1 which looks like it's almost ready... I was just excited to have this in my project, but then wasn't sure when npm update didn't do anything. Thanks again for fixing this quickly! |
@ruxxzebre I think this is another issue with |
Prerequisites
Mongoose version
7.5.0
Node.js version
18.x
MongoDB version
5.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.5
Issue
I am trying to get Typescript typings to work on instance methods defined on my schema. I've followed along in the docs, but I can only get types working on "this" that reflect methods, and not any properties.
Example schema (I pulled from a working example I found on here):
But my typescript doesn't give me the proper type of "this", "firstName" or "lastName"...
I am upgrading my project from an older version of mongoose, typescript, etc. and I swear I used to have proper property types on this.
Typescript version: 5.2.2
Node version 18 and my tsconfig is set up with "strict": true
Thanks for any insight!
The text was updated successfully, but these errors were encountered: