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
-
I'm using mongoose version
5.13.15
.How exactly is typescript supposed to work with mongoose? Look at this :-
I'm getting
isAdmin?: any
from vscode's typescript intellisense when I clearly definedisAdmin: boolean
inInterface_Test
. Is this really how it should work?Other thing :-
If
isAdmin
is required shouldn't mongoose complain if I'm not passing in a value forisAdmin
when 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