validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

Can't be used within remix routes

Open arman94 opened this issue 1 year ago • 5 comments

arman94 avatar Nov 08 '23 10:11 arman94

Hey @arman94 Can you describe this issue?

bhavik001 avatar Nov 11 '23 08:11 bhavik001

Screenshot 2023-11-12 at 18 53 17

Not sure what OP means but I have issues with Remix. Just a regular import:

import isEmail from 'validator/lib/isEmail'
import isEmail from 'validator/es/lib/isEmail'

Results in:

Cannot find module 'validator/lib/isEmail' or its corresponding type declarations.

But the files clearly are there, I can cmd+click it and see the export.

In my tsconfig.json I've got:

{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "target": "ES2022",
  }
}

I can import with the file extension: import isEmail from 'validator/es/lib/isEmail.js', but then when I use it TS whines about it:

This expression is not callable.
  Type 'typeof import("/Users/bob/foo/node_modules/.pnpm/@[email protected]/node_modules/@types/validator/es/lib/isEmail")' has no call signatures.

hilja avatar Nov 12 '23 18:11 hilja

Screenshot 2023-11-12 at 19 10 12

Seems like you're trying to export toString which doesn't exist. Don’t know if it's related.

hilja avatar Nov 12 '23 18:11 hilja

This is the exact issue I have with validator in Remix

arman94 avatar Nov 13 '23 06:11 arman94

Type declarations are not handled in this project, but in the DefinitelyTyped repository; https://github.com/DefinitelyTyped/DefinitelyTyped

WikiRik avatar Nov 13 '23 06:11 WikiRik

Having the same issue here. I have @types/validator added but it's not helping.

aszmyd avatar Feb 29 '24 11:02 aszmyd

I'm closing this issue since this is not something we can fix in this repo. Issues with @types/validator can be reported in the DefinitelyTyped repository; DefinitelyTyped/DefinitelyTyped

WikiRik avatar May 07 '24 20:05 WikiRik