-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Variance RelationshipsThe issue relates to variance relationships between typesThe issue relates to variance relationships between typesHelp WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms: override generic
Code
interface Foo {
method<T>(): T;
}
// Error: Interface 'Bar<T>' incorrectly extends interface 'Foo'.
interface Bar<T extends Node> extends Foo {
method<T2 extends T>(): T2;
}
// Uncommenting this suddenly fixes the error
// interface Foo {
// method<T>(): T;
// }
Full error message:
Interface 'Bar<T>' incorrectly extends interface 'Foo'.
Types of property 'method' are incompatible.
Type '<T2 extends T>() => T2' is not assignable to type '<T>() => T'.
Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
Type 'Node' is not assignable to type 'T'.
Expected behavior: The error should always appear, or always not appear.
Actual behavior: A partial interface mysteriously removes the error
Related Issues: #23960
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Variance RelationshipsThe issue relates to variance relationships between typesThe issue relates to variance relationships between typesHelp WantedYou can do thisYou can do this