-
-
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
pre middleware .save conflict with strict mode #14399
Comments
I tried to reproduce your code in my system with the same version, and its working fine, even with |
yup , still having an err |
Does this error occur when you build your project with TypeScript, or just in your IDE? If with TypeScript, please provide which version of TypeScript you're using. |
Does this issue only appear in your IDE, or when you try to compile? Also, what is The following code ( import { Schema } from 'mongoose';
const userSchema = new Schema({
userId: { type: String, required: true, unique: true },
password: { type: String, required: true },
});
export interface IUser {
userId: string;
password: string;
}
export interface IUserDocument extends IUser,Document {}
userSchema.pre("save",async function (this: IUserDocument, next: Function) {
}
); Command and output:
|
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days |
This issue was closed because it has been inactive for 19 days and has been marked as stale. |
Prerequisites
Mongoose version
8.1.3
Node.js version
20.10.0
MongoDB version
6.0.8
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
22H2 - windows 11
Issue
when writing a pre middleware to encrypt the password while saving it shows me an error
No overload matches this call.
The last overload gave the following error.
Argument of type '"save"' is not assignable to parameter of type 'RegExp | "insertMany"'.ts(2769)
index.d.ts(413, 5): The last overload is declared here.
and i dont know why that middleware called
important to know that when removing the strict mode it works well with no issues
steps to reproduce
add "strict": true in the ts.config
then start creating a model for example a user
setup the interface for user
now just try to add the pre middleware for encrypting the password
and that happended i think
to call that
from the node_moduels
not
The text was updated successfully, but these errors were encountered: