简中文档

no-misused-new

NOTE: this rule is part of the 推荐 rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["推荐"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["no-misused-new"],
      "exclude": ["no-misused-new"]
    }
  }
}

禁止为接口定义 constructor 或为类定义 new

为接口指定 constructor 或为类定义 new 方法是不正确的,应避免这样做。

无效:

class C {
  new(): C;
}

interface I {
  constructor(): void;
}

有效:

class C {
  constructor() {}
}

interface I {
  new (): C;
}

你找到了你需要的东西吗?

编辑此页面
隐私政策