Disallow the declaration of empty interfaces #2300

Closed
opened 2026-04-05 16:57:28 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @chibuike-okpara on 5/17/2022

Disallow the declaration of empty interfaces.

An empty interface is equivalent to its supertype. If the interface does not implement a supertype, then the interface is equivalent to an empty object ({}). In both cases it can be omitted.

INCORRECT

// an empty interface
interface Foo {}

// an interface with only one supertype (Bar === Foo)
interface Bar extends Foo {}

// an interface with an empty list of supertypes
interface Baz {}

CORRECT

// an interface with any number of members
interface Foo {
  name: string;
}

// same as above
interface Bar {
  age: number;
}

// an interface with more than one supertype
// in this case the interface can be used as a replacement of a union type.
interface Baz extends Foo, Bar {}
*Originally created by @chibuike-okpara on 5/17/2022* Disallow the declaration of empty interfaces. An empty interface is equivalent to its supertype. If the interface does not implement a supertype, then the interface is equivalent to an empty object ({}). In both cases it can be omitted. **INCORRECT** ``` // an empty interface interface Foo {} // an interface with only one supertype (Bar === Foo) interface Bar extends Foo {} // an interface with an empty list of supertypes interface Baz {} ``` **CORRECT** ``` // an interface with any number of members interface Foo { name: string; } // same as above interface Bar { age: number; } // an interface with more than one supertype // in this case the interface can be used as a replacement of a union type. interface Baz extends Foo, Bar {} ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#2300