Hi Guys,
This is probably asked lots but I was wondering how you fix this issue?
I have the code:
app.get('/test', (req: Request, res: Response) => {
console.log(req.url);
return res.sendStatus(200);
})
The 2nd parameter's parameters (the call back function parameters) are underlined with the error:
The last overload gave the following error.
Argument of type '(req: Request, res: Response) => express.Response<any, Record<string, any>>' is not assignable to parameter of type 'Application<Record<string, any>>'.
Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Response<...>' is missing the following properties from type 'Application<Record<string, any>>': init, defaultConfiguration, engine, set, and 63 more.```
I was wondering how to fix this? I really have no clue why it is happening so some help would be appreciated.
I am migrating a project from JS to TS and so there is still some other JS code however I am doing the following:
```ts
import express, { Express, Request, Response, NextFunction } from 'express';
And I have installed the @types/express and @types/node packages.
I am also defining the app function correctly I believe so there shouldn't be an issue with that?
const parsedPort: number = process.env.PORT ? parseInt(process.env.PORT) : NaN;
const PORT: number = isNaN(parsedPort) ? 3000 : parsedPort;
const app: Express = express();
https.createServer({ key, cert }, app).listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});
Many thanks for any help provided.