import express = require('express');
import { NextFunction } from "@types/express-serve-static-core";
const router:express.Router = express.Router();
router.get('/', (req: Request, res: Response, next: NextFunction) => {
});
export = router;
Possibly Related: microsoft/TypeScript#11875
Error Message:
Argument of type ‘(req: Request, res: Response, next: NextFunction) => void’ is not assignable to parameter of type ‘RequestHandlerParams’.
Type ‘(req: Request, res: Response, next: NextFunction) => void’ is not assignable to type ‘(RequestHandler | ErrorRequestHandler)[]’.
Property ‘push’ is missing in type ‘(req: Request, res: Response, next: NextFunction) => void’.
@blakeembrey SGTM. If we can get the ball rolling on it now, we can have a very nice reason to upgrade to 4.16 (including TSD).
I’ve been using express typings with a number of projects without any problems. It seems to be me like the code in the initial post is missing 1) importing
Request
andResponse
and 2) are importingNextFunction
from the wrong package.This is what have been working for me:
edit: this is with
npm install --save express @types/express