Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-empty-interface should not fail on an interface with multiple parents #2065

Closed
HamletDRC opened this issue Jan 18, 2017 · 3 comments · Fixed by singapore/lint-condo#223
Closed

Comments

@HamletDRC
Copy link
Contributor

Bug Report

  • TSLint version: 4.3.0
  • TypeScript version: 2.1.4
  • Running TSLint via: grunt tslint

TypeScript code being linted

            interface MyInterface extends First, Second {
            }

An interface with two parents is not empty. It is a common way to merge disparate attributes into a meaningful composition.

For example, we use this by having three interfaces: HasWidth, HasHeight, and a 3rd called HasDimensions that implements the first two. Then there are functions that operate on the appropriate abstraction.

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 18, 2017

Isn't it cleaner to use intersection to merge those types instead of extending them with an empty Interface?

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 18, 2017

type MyInterface = First & Second 

@HamletDRC
Copy link
Contributor Author

Whether or not an alternative is cleaner does not change the fact that an interface with two parents is not empty. The preference for intersection types that you describe may be a valid preference, but it is a different tslint rule that should enforce that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants