【问题标题】:When I use typescript, how can I use the cookie-parser of express当我使用打字稿时,如何使用 express 的 cookie-parser
【发布时间】:2017-07-18 21:15:31
【问题描述】:

我想在 expressjs 中使用 cookie-parser,但是 typescript 找不到 request.cookie 的类型。我该如何解决?

screenshot

【问题讨论】:

  • 我认为您需要快速 cookie 的 .d.ts 定义文件?
  • 我试过了,但是没用。 Request 的接口在 express 中 req 的命名空间中。我想我应该修改 express.d.ts
  • 你找到解决方案了吗?
  • 使用 ( request).cookie 或 (request as any).cookie.

标签: express typescript typescript-typings


【解决方案1】:

只需确保您已从 express 包中导入 Request 类型,而不是本机请求声明类型。

import {Request} from 'express';

【讨论】:

    猜你喜欢
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    • 2017-05-07
    • 2015-03-13
    相关资源
    最近更新 更多