From fac57d46263790b607f28881422aa9aac55d750c Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Thu, 19 Jan 2017 16:00:50 +0100 Subject: [PATCH 1/2] Fix a small issue withing the multer typing --- multer/index.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/multer/index.d.ts b/multer/index.d.ts index 2437f498db..1e388f7630 100644 --- a/multer/index.d.ts +++ b/multer/index.d.ts @@ -48,22 +48,22 @@ declare namespace multer { /** A function used to determine within which folder the uploaded files should be stored. Defaults to the system's default temporary directory. */ destination?: string | ((req: Express.Request, file: Express.Multer.File, callback: (error: Error, destination: string) => void) => void); /** A function used to determine what the file should be named inside the folder. Defaults to a random name with no file extension. */ - filename?: (req: Express.Request, file: Express.Multer.File, callback: (error: Error, filename: string) => void) => void; + filename?: (req: Express.Request, file: Express.Multer.File, callback: (error?: Error, filename?: string) => void) => void; } interface Instance { - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - single(): express.RequestHandler; - /** Accept a single file with the name fieldname. The single file will be stored in req.file. */ - single(fieldame: string): express.RequestHandler; - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - array(): express.RequestHandler; - /** Accept an array of files, all with the name fieldname. Optionally error out if more than maxCount files are uploaded. The array of files will be stored in req.files. */ - array(fieldame: string, maxCount?: number): express.RequestHandler; - /** Accept a mix of files, specified by fields. An object with arrays of files will be stored in req.files. */ - fields(fields: Field[]): express.RequestHandler; - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - any(): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + single(): express.RequestHandler; + /** Accept a single file with the name fieldname. The single file will be stored in req.file. */ + single(fieldame: string): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + array(): express.RequestHandler; + /** Accept an array of files, all with the name fieldname. Optionally error out if more than maxCount files are uploaded. The array of files will be stored in req.files. */ + array(fieldame: string, maxCount?: number): express.RequestHandler; + /** Accept a mix of files, specified by fields. An object with arrays of files will be stored in req.files. */ + fields(fields: Field[]): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + any(): express.RequestHandler; } } From c779cebd7f18a885b1e956020d884438c1e5566e Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Thu, 19 Jan 2017 16:07:39 +0100 Subject: [PATCH 2/2] Better typing yet --- multer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multer/index.d.ts b/multer/index.d.ts index 1e388f7630..53fdcd7add 100644 --- a/multer/index.d.ts +++ b/multer/index.d.ts @@ -48,7 +48,7 @@ declare namespace multer { /** A function used to determine within which folder the uploaded files should be stored. Defaults to the system's default temporary directory. */ destination?: string | ((req: Express.Request, file: Express.Multer.File, callback: (error: Error, destination: string) => void) => void); /** A function used to determine what the file should be named inside the folder. Defaults to a random name with no file extension. */ - filename?: (req: Express.Request, file: Express.Multer.File, callback: (error?: Error, filename?: string) => void) => void; + filename?: (req: Express.Request, file: Express.Multer.File, callback: (error: Error | null, filename: string) => void) => void; } interface Instance {