Closed
Description
π Search Terms
"this is type", "return type", "implement", "inherit", "not checked"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "this is"
β― Playground Link
π» Code
interface A {
method1(): this is {
a: 1
};
method2(): boolean;
}
class B implements A {
// Why no error?
method1() { }
// @ts-expect-error Type 'void' is not assignable to type 'boolean'
method2() { }
}
π Actual behavior
B.method1
produces no error, and its return type is void
.
π Expected behavior
B.method1
should be an error.
Additional information about the issue
If A
in the above example is a class, and B
is extending A
, this bug will also happen.