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

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

Open
cqulun123 opened this issue Sep 20, 2022 · 0 comments
Open

Comments

@cqulun123
Copy link

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

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

1 participant