Definitelytyped: Question: @types/multer import Multer.File type

Created on 2 Aug 2017  路  8Comments  路  Source: DefinitelyTyped/DefinitelyTyped

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.

Most helpful comment

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

All 8 comments

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

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.

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

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

import multer = require('multer');

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

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.

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. 馃槃

Was this page helpful?
0 / 5 - 0 ratings