Skip to content

thisType is not narrowedΒ #44091

Closed
Closed
@Zzzen

Description

@Zzzen

Bug Report

πŸ”Ž Search Terms

thisType is not narrowed

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class Base {
  f() {
    if (this instanceof D1) {
      const s: this = this;
      s.f1();
      this.f1();
    }
  }
}

class D1 {
  f1() {}
}

πŸ™ Actual behavior

compiler throws an error on s.f1(): Property 'f1' does not exist on type 'Base'.

πŸ™‚ Expected behavior

should have no error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions