Just installed class-validator into a new Nest.js project, also manually intalled types.
Getting the above error for basically all validators when trying to start app:
node_modules/class-validator/validation/Validator.d.ts:383:38 - error TS2503: Cannot find namespace 'ValidatorJS'.
383 isISSN(value: unknown, options?: ValidatorJS.IsISSNOptions): boolean;
can you share a repo ? I am not having any problems so I can tr to reproduce and if found , fix the problem
Can close this, not sure what happened, but doing a yarn install somehow fixed it...?
This is now happening on a new project, so bizarre...
This is the cause of the issue https://github.com/DefinitelyTyped/DefinitelyTyped/issues/40477
I'm using validator itself in my project and I'm running into this issue as well.
$ yarn add -D @types/[email protected]Solves the issue in the meantime
Looks like breaking changes in @types/validator. But why you need @types/validator in your project? validator and @types/validator are only internal class-validator dependencies. I think you can completely remove them from your package.json.
I'm using import { normalizeEmail } from 'validator'; in my codebase.
public findByEmail(unsanitizedEmail: string | string[]) {
const whereCondition = (email: string) => [
{ email },
{ email: normalizeEmail(email) },
{ unsanitizedEmail: email },
{ unsanitizedEmail: normalizeEmail(email) },
];
return this.findOne({
where: Array.isArray(unsanitizedEmail)
? flatten(unsanitizedEmail.map(whereCondition))
: whereCondition(unsanitizedEmail),
});
}
@vlapo I need validator and @types/validator because I am using sequelize-typescript (https://www.npmjs.com/package/sequelize-typescript) which also has them as a dependency. They should be made peer depedencies of this lib to avoid conflicts like this.
@cjancsar try to add this to your tsconfig.json
{
"compilerOptions": {
...
"typeRoots": ["./node_modules/*/node_modules/@types/"]
}
...
}
Please try [email protected]. It should be fixed
@vlapo still facing same issue on [email protected]
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@cjancsar try to add this to your
tsconfig.json