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

Unable to use express-validator with TypeScript 2.3.4 #350

Closed
taicho opened this issue Jun 10, 2017 · 4 comments · Fixed by #352
Closed

Unable to use express-validator with TypeScript 2.3.4 #350

taicho opened this issue Jun 10, 2017 · 4 comments · Fixed by #352

Comments

@taicho
Copy link
Contributor

taicho commented Jun 10, 2017

Based on how the typings are written (the ones that ship with express-validator). I am unable to import the library without compile-time errors.

I've tried:
import * as expressValidator from 'express-validator';
import {ExpressValidator} from 'express-validator';

Both of which result in:
Module '"express-validator"' resolves to a non-module entity and cannot be imported using this construct.'

Is anybody else running into this issue? I figure a workaround would be to delete index.d.ts from node_modules/express-validator/ but I feel concerned about this issue coming up again when the next release of express-validator is published...

Thanks in advance!

@baptistelambert
Copy link

I had the same problem and tried importing like so:

import expressValidator = require('express-validator')

Not the prettiest syntax but it works on my side.

@taicho
Copy link
Contributor Author

taicho commented Jun 11, 2017

@baptistelambert Thanks. :) Guess I'll have to go the same route too. ;-/

@tylerpalmerdev
Copy link

Importing each individual method from 'express-validator/check' works for me:

import { check, body, query, param, validationResult } from 'express-validator/check';

You then have access to each method within the file.

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants