My Express server has the following code:
import express from "express";
import helmet from "helmet";
import cors from "cors";
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
and I'm getting errors on both the helmet() and express.json() calls:
helmet(): No overload matches this call. The last overload gave the following error. Argument of type '(req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => void' is not assignable to parameter of type 'PathParams'. Type '(req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => void' is missing the following properties from type '(string | RegExp)[]': pop, push, concat, join, and 27 more.ts(2769)
express.json(): No overload matches this call. The last overload gave the following error. Argument of type 'NextHandleFunction' is not assignable to parameter of type 'PathParams'. Type 'NextHandleFunction' is missing the following properties from type '(string | RegExp)[]': pop, push, concat, join, and 27 more.ts(2769)
I'm using Express 4.17.1, TypeScript 4.3.5, and Helmet 4.6.0.
I always used helmet and express.json like this, but recently I started seeing these typescript errors.
Does anyone know how to fix these?
Thank you.
@types/node
. Could you try updating that? – Evan Hahn