no-empty-interface
注意: 此规则是
recommended
规则集的一部分。在
deno.json
中启用完整规则集{ "lint": { "tags": ["recommended"] } }
使用 Deno CLI 启用完整规则集
deno lint --tags=recommended
禁止声明空接口。
没有成员的接口没有任何作用。此规则将捕获这些情况,将其视为不必要的代码或错误的空实现。
无效
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 {}