TypeScript Version: 2.1.1
Code (playground link)
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.
TypeScript Version: 2.1.1
Code (playground link)
Expected behavior:
No compilation errors
Actual behavior:
An error that says:
But
methodin class B is returning an object that is compatible with the declared interface an the error doesn't show up on class Amethod.