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
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
}
}
"An interface declaring no members is equivalent to its supertype"
No error
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:
@Dok11 Use export type MyItem = Item;
.
Amazing! Thanks!
Most helpful comment
@Dok11 Use
export type MyItem = Item;
.