Node.js 如何使用TypeScript在express中键入app.get(';/events';,(req,res)

Node.js 如何使用TypeScript在express中键入app.get(';/events';,(req,res),node.js,typescript,express,Node.js,Typescript,Express,我想知道在express中使用app.get时(req,res)=>的类型注释是什么 app.get('/events', (req, res) => { // SSE Setup res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'ke

我想知道在express中使用
app.get
(req,res)=>
的类型注释是什么

app.get('/events', (req, res) => {
        // SSE Setup
        res.writeHead(200, {
            'Content-Type': 'text/event-stream',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
        });
        res.write('\n');

        sseEvents(req, res);
    });

您需要有
@types/express
npmi-D@types/express
),然后才能使用

import { Request, Response } from 'express';
app.get('/events', (req: Request, res: Response) => {
  // your code
});