deno.com

禁止空接口

注意:此规则是 recommended 规则集的一部分。
deno.json 中启用完整集合
{
  "lint": {
    "rules": {
      "tags": ["recommended"]
    }
  }
}
使用 Deno CLI 启用完整集合
deno lint --rules-tags=recommended
通过将此规则添加到 deno.json 中的 includeexclude 数组,可以将其明确地包含或排除在当前标签中的规则之外。
{
  "lint": {
    "rules": {
      "include": ["no-empty-interface"],
      "exclude": ["no-empty-interface"]
    }
  }
}

禁止声明空接口。

没有成员的接口没有任何作用。此规则将捕获这些情况,将其视为不必要的代码或错误的空实现。

无效示例

interface Foo {}

有效示例

interface Foo {
  name: string;
}

interface Bar {
  age: number;
}

// Using an empty interface with at least one extension are allowed.

// Using an empty interface to change the identity of Baz from type to interface.
type Baz = { profession: string };
interface Foo extends Baz {}

// Using an empty interface to extend already existing Foo declaration
// with members of the Bar interface
interface Foo extends Bar {}

// Using an empty interface as a union type
interface Baz extends Foo, Bar {}

您找到所需内容了吗?

隐私政策