Validator.js: Could not find a declaration file for module with TypeScript

Created on 30 Nov 2019  路  13Comments  路  Source: validatorjs/validator.js

For import isEmail from 'validator/es/lib/isEmail';' Could not find a declaration file for module 'validator/es/lib/isEmail'`

But for import isEmail from 'validator/lib/isEmail';

It's ok.

help wanted 馃悰 bug

Most helpful comment

The tree shakable path does not appear to be working

All 13 comments

The tree shakable path does not appear to be working

@banjankri -- could you please help look into this, re: #1015

Related: #1204. Wish I had time to volunteer to convert this project to TypeScript.

@steida would you be able to provide some further details on this issue please? Like typescript version used, tsconfig, whether you are using typings for this library etc. I am using the very same imports in a TS project and it seem to be working fine. Also exact version of validator.js used could help to pinpoint the culprit.

As I wrote, try this example https://github.com/validatorjs/validator.js#tree-shakeable-es-imports

"validator": "^13.0.0"
"@types/validator": "^13.0.0",

Still does not work for es6.

Using exatly this import in my project. Upgraded to pointed versions of validator and @types/validator and still cannot seem to reproduce the issue. All seems fine.

@steida Could you share some more information re your typescript/tsconfig please? Or provide sample repository ideally.

Not sure if it helps, but removing the strict flag fixes the error. However should you want to enforce that you'd need to either amend the typings for the library or add a typing locally or a path mapping in your tsconfig.

The way to go would be amending the typings for the library or as mentioned before converting it to typescript altogether.

Remove 'strict' is nogo. Please, do not castrate TypeScript.

Opened up a PR with DefinitelyTyped so castration should not be necessary :)

@steida the PR got merged, please give it a go using the latest typings.

@banjankri Great, TypeScript error is gone.

Unfortunately, tree shakable path still does not appear to be working.

Screenshot 2020-06-25 at 00 15 17

But it's another error so I am closing this issue. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

woverton picture woverton  路  4Comments

MindRapist picture MindRapist  路  4Comments

karladler picture karladler  路  3Comments

philfreo picture philfreo  路  3Comments

zilahir picture zilahir  路  3Comments