首页 > 解决方案 > TS2339:“头盔”类型上不存在属性“featurePolicy”

问题描述

我有由Helmet定义的安全规则的应用程序。但是,安装时@types/helmet出现以下错误TS2339: Property 'featurePolicy' does not exist on type 'Helmet'.。代码如下:

import * as express from 'express';
import * as helmet from 'helmet';
import { Express } from 'express';

const expressApp: Express = express(); // Create Express instance.

// Limit website features by implementing Feature Policy.
expressApp.use(
  helmet.featurePolicy({
    features: {
      fullscreen: ["'self'"],
      payment: ["'none'"],
      syncXhr: ["'none'"]
    }
  })
);

链接到功能策略,它是头盔包的一部分:https ://helmetjs.github.io/docs/feature-policy/

标签: javascripttypescriptexpresstypescript-typingshelmet.js

解决方案


推荐阅读