richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 259 forks source link

fileUpload TypeSrcipt check error TS2769: No overload matches this call. #330

Open cqulun123 opened 1 year ago

cqulun123 commented 1 year ago

I used fileUpload in my project and use tsc-silent to check the type, it raised below error: admin@admin:/home/admin/project$ tsc-silent -p server/jsconfig.json --suppressConfig server/tsc-silent.config.cjs Using TypeScript compiler version 4.4.3 from /home/admin/project /node_modules/typescript/lib/typescript.js server/api/router.js:150:5 - error TS2554: Expected 1 arguments, but got 0.

150 fileUpload(),


  server/node_modules/express-fileupload/lib/index.js:30:19
    30 module.exports = (options) => {
An argument for 'options' was not provided.

server/router.js:150:5 - error TS2769: No overload matches this call. The last overload gave the following error. Argument of type 'Function' is not assignable to parameter of type 'RequestHandlerParams<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'. Type 'Function' is not assignable to type '(ErrorRequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>> | RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<...>>)[]'.

150 fileUpload(),


  server/node_modules/@types/express-serve-static-core/index.d.ts:163:5
    163     <
            ~
    164         P = ParamsDictionary,
...
172         ...handlers: Array<RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, Locals>>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173     ): T;
    ~~~~~~~~~
The last overload is declared here.

Visible errors: 2, suppressed errors: 2828

And my code is written like this:

import fileUpload from 'express-fileupload'; import express from 'express';

const apiRouter = function apiRouter() { const router = express.Router({ mergeParams: true }); router.post( '/upload', fileUpload(), ), (req, res) => { .... }); .... return router; };

}

export { apiRouter };

And documented type seems has no problem, so how can i slove this ts check type error?

ts_issue