You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceDetails{name: "Alex"|"Dan",age:number}classA{method(): Details{return{name: "Alex",// this doesn't fire any errorage:30}}}classBextendsA{method(){return{name: "Alex",// this fires an errorage:50}}}
Expected behavior:
No compilation errors
Actual behavior:
An error that says:
Class 'B' incorrectly extends base class 'A'.
Types of property 'method' are incompatible.
Type '() => { name: string; age: number; }' is not assignable to type '() => Details'.
Type '{ name: string; age: number; }' is not assignable to type 'Details'.
Types of property 'name' are incompatible.
Type 'string' is not assignable to type '"Alex" | "Dan"'.
But method in class B is returning an object that is compatible with the declared interface an the error doesn't show up on class A method.
The text was updated successfully, but these errors were encountered:
However, I don't have to add a declaration for the method() in class B since the class B is extending another class (B) where the method has a return declaration.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.1.1
Code (playground link)
Expected behavior:
No compilation errors
Actual behavior:
An error that says:
But
method
in class B is returning an object that is compatible with the declared interface an the error doesn't show up on class Amethod
.The text was updated successfully, but these errors were encountered: