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

Could not find a declaration file for module with TypeScript #1208

Closed
steida opened this issue Nov 30, 2019 · 13 comments
Closed

Could not find a declaration file for module with TypeScript #1208

steida opened this issue Nov 30, 2019 · 13 comments

Comments

@steida
Copy link

steida commented Nov 30, 2019

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.

@Jdombrowski
Copy link

The tree shakable path does not appear to be working

@profnandaa
Copy link
Member

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

@dandv
Copy link

dandv commented May 28, 2020

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

@banjankri
Copy link
Contributor

@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.

@steida
Copy link
Author

steida commented Jun 16, 2020

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.

@banjankri
Copy link
Contributor

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.

@steida
Copy link
Author

steida commented Jun 19, 2020

@banjankri https://codesandbox.io/s/magical-almeida-uw02b?file=/src/index.ts

Screenshot 2020-06-20 at 01 09 51

@banjankri
Copy link
Contributor

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.

@steida
Copy link
Author

steida commented Jun 22, 2020

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

@banjankri
Copy link
Contributor

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

@banjankri
Copy link
Contributor

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

@steida
Copy link
Author

steida commented Jun 24, 2020

@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

@steida
Copy link
Author

steida commented Jun 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants