question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix: Update to `class-validator@0.13.2` generates `error TS7016: Could not find a declaration file for module 'validator'.`

See original GitHub issue

Description

Updating a project from class-validator@0.13.1 to class-validator@0.13.2 generates 16 error TS7016: Could not find a declaration file for module 'validator'. messages on tsc transpilation when tsconfig.json is configured with the default skipLibCheck: false.

Minimal code-snippet showcasing the problem class-validator@0.13.2 removes @types/validator from the package.json dependencies, which now requires consuming applications to manually add @types/validator to avoid error TS7016 on transpilation when the default skipLibCheck: false.

Expected behavior

Update from 0.13.1 to 0.13.2 should allow project to build without error.

Actual behavior

node_modules/class-validator/types/decorator/string/IsAlpha.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsAlphanumeric.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsCurrency.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '/Users/keith.gillette/Code/TaskTrain/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsDateString.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsDecimal.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsEmail.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsFQDN.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsHash.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsIdentityCard.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsISO8601.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsISSN.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsMacAddress.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsMobilePhone.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsNumberString.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsPostalCode.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~

node_modules/class-validator/types/decorator/string/IsUrl.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'validator'. '~/node_modules/validator/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/validator` if it exists or add a new declaration (.d.ts) file containing `declare module 'validator';`

2 import ValidatorJS from 'validator';
                          ~~~~~~~~~~~


Found 16 errors.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:25
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
DnOberoncommented, Nov 26, 2021

Really don’t want to sticky my project to the previous version, any movement on this?

8reactions
kliuiev-iocommented, Nov 22, 2021

Fixes locally by npm i --save-dev @types/validator but it’s still a bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error TS7016: Could not find a declaration file for ...
Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare module 'XYZ';. If XYZ is a direct...
Read more >
Could not find a declaration file for module 'module-name ...
Here are two other solutions. When a module is not yours - try to install types from @types : npm install -D @types/module-name....
Read more >
Fixing the TS7016 Error | Atomist Blog
Could not find declaration file -- How do you get past the TS7016? This article highlights the eight best and worst fixes.
Read more >
Could not find declaration file for module 'X' Error | bobbyhadz
The error "Could not find declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve the...
Read more >
Error: src/algolia.ts(1,27): error TS7016: Could not find a ...
... error TS7016: Could not find a declaration file for module ... as a dev dependency to my package.json but this does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found