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

Interface declaring a concrete type of a generic interface marked "equivalent to its supertype" #2740

Closed
donatj opened this issue May 11, 2017 · 7 comments

Comments

@donatj
Copy link

donatj commented May 11, 2017

There appears to be an issue when using an interface to extend a Generic type into a Concrete Interface where it triggers "An interface declaring no members is equivalent to its supertype"

This became an issue when I updated earlier today from tslint version 4.5.1 -> 5.2.0

Bug Report

  • TSLint version: 5.2.0
  • TypeScript version: 2.3.2
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

export type Callback<t> = (result: t) => void;

export interface AuthCallback extends Callback<Auth> {}

with tslint.json configuration:

{
    "extends": "tslint:recommended",
    "rules": {
        "class-name": true,
        "indent": [true, "tabs"],
        "quotemark": false,
        "align": false,
        "typedef-whitespace": false,
        "interface-name": false,
        "triple-equals": false,
        "whitespace": false,
        "max-line-length": false,
        "eofline": false,
        "no-empty": false,
        "one-variable-per-declaration": false,
        "member-ordering": false,
        "max-classes-per-file": false,
        "no-bitwise": false,
        "no-console": false
    }
}

Actual behavior

"An interface declaring no members is equivalent to its supertype"

Expected behavior

No error

@ghost
Copy link

ghost commented May 11, 2017

You can use --stylish or --verbose output to see which rule is failing. (#2228)
In this case it's no-empty-interface.
You can just use export type AuthCallback = Callback<Auth>; instead.

@donatj
Copy link
Author

donatj commented May 11, 2017

@andy-ms I did essentially as much to shut it up, but I still feel like it's a bug in the rule

@ghost
Copy link

ghost commented May 11, 2017

The point of the rule is to discourage any empty interface. What does the generic change?

@donatj
Copy link
Author

donatj commented May 11, 2017

@andy-ms I apologize, you are correct after a bit of testing 😏 . I will close this issue.

I was thinking that in cases where the supertype was an interface with members, you'd have to extend it, but no. I was wrong. Your solution works fine in that case as well.

@Dok11
Copy link

Dok11 commented Oct 30, 2017

@donatj what about this case:

export interface MyItem extends MyItem {
}

Equal don't work:
image

@ghost
Copy link

ghost commented Oct 30, 2017

@Dok11 Use export type MyItem = Item;.

@Dok11
Copy link

Dok11 commented Oct 30, 2017

Amazing! Thanks!

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

No branches or pull requests

3 participants