Tslint: Interface declaring a concrete type of a generic interface marked "equivalent to its supertype"

Created on 11 May 2017  ·  7Comments  ·  Source: palantir/tslint

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

Not A Bug

Most helpful comment

@Dok11 Use export type MyItem = Item;.

All 7 comments

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.

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

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

@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.

@donatj what about this case:

export interface MyItem extends MyItem {
}

Equal don't work:
image

@Dok11 Use export type MyItem = Item;.

Amazing! Thanks!

Was this page helpful?
0 / 5 - 0 ratings