Skip to content
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

fix: Cannot find namespace 'ValidatorJS' in 0.14.x #2370

Closed
mhp-borisbojic opened this issue Jan 11, 2024 · 8 comments
Closed

fix: Cannot find namespace 'ValidatorJS' in 0.14.x #2370

mhp-borisbojic opened this issue Jan 11, 2024 · 8 comments
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@mhp-borisbojic
Copy link

Description

With version 0.14.x of class-validator, our tsc (5.3.3) build command suddenly fails.

Minimal code-snippet showcasing the problem

tsc -p tsconfig.build.json  

../../node_modules/class-validator/types/decorator/string/IsAlpha.d.ts:8:58 - error TS2833: Cannot find namespace 'ValidatorJS'. Did you mean 'validator'?

8 export declare function isAlpha(value: unknown, locale?: ValidatorJS.AlphaLocale): boolean;
                                                           ~~~~~~~~~~~

../../node_modules/class-validator/types/decorator/string/IsAlpha.d.ts:13:42 - error TS2833: Cannot find namespace 'ValidatorJS'. Did you mean 'validator'?

13 export declare function IsAlpha(locale?: ValidatorJS.AlphaLocale, validationOptions?: ValidationOptions): PropertyDecorator;
                                            ~~~~~~~~~~~

../../node_modules/class-validator/types/decorator/string/IsAlphanumeric.d.ts:8:65 - error TS2833: Cannot find namespace 'ValidatorJS'. Did you mean 'validator'?

8 export declare function isAlphanumeric(value: unknown, locale?: ValidatorJS.AlphanumericLocale): boolean;
                                                                  ~~~~~~~~~~~

../../node_modules/class-validator/types/decorator/string/IsAlphanumeric.d.ts:13:49 - error TS2833: Cannot find namespace 'ValidatorJS'. Did you mean 'validator'?

13 export declare function IsAlphanumeric(locale?: ValidatorJS.AlphanumericLocale, validationOptions?: ValidationOptions): PropertyDecorator;
                                                   ~~~~~~~~~~~

../../node_modules/class-validator/types/decorator/string/IsCurrency.d.ts:8:62 - error TS2833: Cannot find namespace 'ValidatorJS'. Did you mean 'validator'?

8 export declare function isCurrency(value: unknown, options?: ValidatorJS.IsCurrencyOptions): boolean;

tsconfigs:

  "extends": "./tsconfig.json",
  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "esModuleInterop": true
  },
  "exclude": ["node_modules", "dist"]
}

package.json

"dependencies": {
    "@aws-sdk/client-s3": "^3.473.0",
    "@aws/dynamodb-data-mapper": "^0.7.3",
    "@aws/dynamodb-data-mapper-annotations": "^0.7.3",
    "@aws/dynamodb-expressions": "^0.7.3",
    "@nestjs/common": "^10.2.10",
    "@nestjs/core": "^10.2.10",
    "@nestjs/platform-express": "^10.2.10",
    "@nestjs/swagger": "^7.1.17",
    "aws-lambda": "^1.0.7",
    "aws-sdk": "^2.1518.0",
    "aws-serverless-express": "^3.4.0",
    "axios": "^1.6.2",
    "axios-retry": "^4.0.0",
    "class-transformer": "^0.5.1",
    "class-validator": "0.13.2",
    "cls-hooked": "^4.2.2",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-validator": "^7.0.1",
    "https-proxy-agent": "^7.0.2",
    "json5": "^2.2.3",
    "jsonwebtoken": "^9.0.2",
    "jwks-rsa": "^3.1.0",
    "moment": "^2.29.4",
    "node-cache": "^5.1.2",
    "node-request-context": "^1.0.5",
    "request-context": "^2.0.0",
    "rimraf": "^5.0.5",
    "rxjs": "^7.8.1",
    "sinon": "^17.0.1",
    "swagger-ui-express": "^5.0.0",
    "uuid": "^9.0.1",
    "winston": "^3.11.0",
    "xkpasswd": "^1.0.5"
  },
  "devDependencies": {
    "@nestjs/testing": "^10.2.10",
    "@types/express": "^4.17.21",
    "@types/got": "^9.6.12",
    "@types/jest": "^29.5.11",
    "@types/node": "^20.10.4",
    "@types/supertest": "^2.0.16",
    "@types/uuid": "^9.0.7",
    "@typescript-eslint/eslint-plugin": "6.18.1",
    "@typescript-eslint/parser": "6.18.1",
    "eslint": "8.56.0",
    "eslint-config-prettier": "9.1.0",
    "eslint-plugin-prettier": "5.1.3",
    "husky": "^8.0.3",
    "jest": "^29.7.0",
    "lint-staged": "^15.2.0",
    "prettier": "^3.1.1",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.1",
    "ts-node": "^10.9.2",
    "tsc-watch": "^6.0.4",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.3.3"
  },

Expected behavior

Tsc build command works as before.

Actual behavior

It worked for 2 months without issues, but now results in the output above.
If we set back the version to 0.13.x, it works without any issues or error messages.

@mhp-borisbojic mhp-borisbojic added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Jan 11, 2024
@jonparkdev
Copy link

0042559

Looks like its from the latest commit

@sph3rex
Copy link
Contributor

sph3rex commented Jan 11, 2024

I think it was fixed in tag 0.14.1 but I guess you forgot to bump also the package.json version since it still says 0.14.0. Probably because of that there's no npm release?! 0042559 in fact fixes the imports, because @types decided that it's a good moment to update all the validator versions since 13.0.0 in the release 2 days ago.

PS: was wondering why you don't release separate tarballs with cjs/, esm2015/ since right now people are stucked waiting for npm release rather than using the git typestack/class-validator#0.14.1 tag.

@braaar
Copy link
Member

braaar commented Jan 12, 2024

My bad, folks, this should be fixed in a few minutes.

@braaar
Copy link
Member

braaar commented Jan 12, 2024

I need an approval on #2373 in order to merge it (develop is protected, so I can't push directly myself and my PR needs an approval)

@fabrice-toussaint
Copy link

How long does it take for NPM to pick this up?

@braaar
Copy link
Member

braaar commented Jan 12, 2024

This was my mistake. The release has now succeeded. See comments in #2371 and #2373

Sorry about the mess.

@braaar braaar closed this as completed Jan 12, 2024
@sph3rex
Copy link
Contributor

sph3rex commented Jan 12, 2024

This has been fixed in the new published version: 0.14.1. Thank you @braaar !

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

5 participants