Microsoft/TypeScript
View on GitHubabstract type guard does not narrow when keyed with a unique symbol
Open
#62,247 opened on Aug 10, 2025
BugDomain: check: Control FlowHelp Wanted
Description
🔎 Search Terms
abstract type guard symbol
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about abstract type guard
⏯ Playground Link
💻 Code
const isBar = Symbol("isBar");
abstract class Foo {
abstract isBar(): this is Bar;
abstract [isBar](): this is Bar;
method(): void {
if (this[isBar]()) {
// This should not be an error, it should work the same as .isBar()
this.barMethod();
} else if (this.isBar()) {
this.barMethod();
}
}
}
class Bar extends Foo {
override isBar(): this is Bar {
return true;
}
override [isBar](): this is Bar {
return true;
}
barMethod(): void {}
}
🙁 Actual behavior
TS reports an error:
Property 'barMethod' does not exist on type 'Foo'. Did you mean 'method'?(2551)
🙂 Expected behavior
No error should happen here, the type guard should work the same as the non-symbol version of the method.
Additional information about the issue
No response