Replies: 1 comment
-
|
That's correct. Mongoose does type casting and doesn't throw an error if const test = new Test({});
test.isAdmin = true;
await test.save();Also, you have a default, so there really is no need to pass |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using mongoose version
5.13.15.How exactly is typescript supposed to work with mongoose? Look at this :-

I'm getting
isAdmin?: anyfrom vscode's typescript intellisense when I clearly definedisAdmin: booleaninInterface_Test. Is this really how it should work?Other thing :-

If
isAdminis required shouldn't mongoose complain if I'm not passing in a value forisAdminwhen creating the document like this one :-const test = new Test({});Also let me know if I'm implementing typescript correctly with mongoose.
Beta Was this translation helpful? Give feedback.
All reactions