Closed
Description
⏯ Playground Link
Issue Type: Bug
This error is only shown when using the TypeScript-Server not when compiling code.
When using an generic class with a method as type guard, it will only be validated correctly if you do not extend the generic type.
The first class is ok but the second shows an error on "this.f(val)" even though nothing changed
class TestClass<T> {
typeguard(val: unknown): val is T {
return true;
}
f(v: number): void {}
h(v: T): void {}
func(val: T | number): void {
if (this.typeguard(val)) {
this.h(val);
return;
}
this.f(val);
}
}
class TestClass2<T extends Date> {
typeguard(val: unknown): val is T {
return true;
}
f(v: number): void {}
h(v: T): void {}
func(val: T | number): void {
if (this.typeguard(val)) {
this.h(val);
return;
}
this.f(val);
}
}