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

Question: @types/multer import Multer.File type #18569

Closed
dannyhuly opened this issue Aug 2, 2017 · 8 comments
Closed

Question: @types/multer import Multer.File type #18569

dannyhuly opened this issue Aug 2, 2017 · 8 comments

Comments

@dannyhuly
Copy link

Hi,

Is it possible to import the Multer.File interface from @types/multer d.ts file ?

I was unable to import it directly with import { File } from 'multer';.
Is there something I'm missing ?

Thanks.

@BendingBender
Copy link
Contributor

It should be available via the global namespace Express.Multer.File.

@dannyhuly
Copy link
Author

Was able to reach it with importing the express namespace first

import { Express } from 'express';

let multerFile: Express.Multer.File;

@BendingBender Thanks for the help.
Didn't notices that Multer is under the Express namespace.

@fwoelffel
Copy link

Is there any particular reason for this to be declared in an Express namespace?

@benwinding
Copy link

benwinding commented Apr 8, 2019

I needed to do the following to use a multer File type

import 'multer';
const multer = require('multer');
let multerFile: Express.Multer.File;

A bit ridiculous....

@MistrySaurabh
Copy link

import multer = require('multer');

@george-norris-salesforce
Copy link

george-norris-salesforce commented Sep 17, 2020

So you can't just use Multer.File globally? Why?

@canove
Copy link

canove commented Sep 22, 2020

So you can't just use Multer.File globally? Why?

I just used:

interface Request {
  media: Express.Multer.File;
  ticket: Ticket;
}

Without importing express first.. So maybe its available globally.

@diegoazh
Copy link
Contributor

diegoazh commented Sep 23, 2020

I have a tricky question about why VsCode tell me that Express is never read and I currently use Express.Multer.File, how can I solve it? 🤔
image
image

UPDATE
I found the solution, I note that Express is a global variable then I set it on globals key of Eslint and after that, I don't need to import Express anymore I just use it on my code like Express.Multer.File. 😄

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

No branches or pull requests

8 participants