The built routes.ts is not valid against the multer type definitions. An excess property multiple is populated on an object literal that is not defined on the multer.Multer.Field
You can also just create a handler as described in the expected behaviour section above
Context (Environment)
Version of the library: v6.3.1
Version of NodeJS: v20.x.x
Version of Typescript: v5.4.5
Version of Multer: 1.4.5-lts.1
Confirm you were using yarn not npm: [ ]
Detailed Description
When using either @UploadedFile or @UploadedFiles to configure a form post to do a file upload the built routes.ts contains
in the request handler the code:
The problem with this is the type of multer.Multer.Field doesn't actually contain a property multiplesee types package. Typescript therefore throw a build error:
src/routes.ts:1571:56 - error TS2353: Object literal may only specify known properties, and '"multiple"' does not exist in type 'Field'.
1571 upload.fields([{"name":"file","maxCount":1,"multiple":false}]),
Honestly maybe I'm missing something obvious as that field was clearly added in the above PR with intent. Looking at multer's source code however I cannot see anything that references a property multiple on a field.
When using either
@UploadedFile
or@UploadedFiles
to configure a form post to do a file upload the builtroutes.ts
file contains invalid code.Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
A handler with a file upload should stil compile to valid typescript which is compatible with multer type definitions:
Current Behavior
The built
routes.ts
is not valid against the multer type definitions. An excess propertymultiple
is populated on an object literal that is not defined on themulter.Multer.Field
Possible Solution
Remove this line https://github.com/lukeautry/tsoa/blame/d4a33015a7c0671cae8c24aae5afa3ea1fe44064/packages/cli/src/routeGeneration/routeGenerator.ts#L113 as it doesn't seem to add anything multer expects?
Steps to Reproduce
We've hit this on all our repos that do file upload. https://github.com/digicatapult/sqnc-matchmaker-api/pull/385 is one example.
You can also just create a handler as described in the expected behaviour section above
Context (Environment)
Version of the library: v6.3.1 Version of NodeJS: v20.x.x Version of Typescript: v5.4.5 Version of Multer: 1.4.5-lts.1
Detailed Description
When using either
@UploadedFile
or@UploadedFiles
to configure a form post to do a file upload the builtroutes.ts
contains in the request handler the code:The problem with this is the type of
multer.Multer.Field
doesn't actually contain a propertymultiple
see types package. Typescript therefore throw a build error:I came across this during an upgrade to tsoa v6.3.0 but it also applied to the latest v6.3.1. This change was introduced in https://github.com/lukeautry/tsoa/pull/1620
Honestly maybe I'm missing something obvious as that field was clearly added in the above PR with intent. Looking at
multer
's source code however I cannot see anything that references a propertymultiple
on a field.Breaking change?
N/A