Avoid the declaration of empty interfaces

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Metadata

ID: typescript-code-style/no-empty-interface

Language: TypeScript

Severity: Notice

Category: Best Practices

Description

Do not use empty interfaces.

Non-Compliant Code Examples

interface Foo {}
interface Foo extends {}
interface Bar extends Foo {}
interface Foo extends Array<number> {}
interface Foo extends Array<number | {}> {}
interface Foo extends Array<Bar> {}
interface Foo extends R {}
interface Foo<T> extends Bar<T> {}
declare module FooBar { type Baz = typeof baz; export interface Bar extends Baz {} }
interface Foo {

}

Compliant Code Examples

interface Foo { name: string; }
interface Foo { name: string; }
interface Bar { age: number; }

// valid because extending multiple interfaces can be used instead of a union type
interface Baz extends Foo, Bar {}
interface Foo { name: string; }
interface Foo { props: string; }
class Bar {}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis