profile
viewpoint

Ask questionsIncorrect refinement using `instanceof`

Example:

class A {
  foo(x: string) {
  }
}

class B extends A {
  foo(x: number) {
    return x.toFixed();
  }
}

function test(a: A | B | {}) {
  if (a instanceof A) {
    a.foo('')
  }
}

a is refined to be an A instead of A | B, which leads to a runtime error.

JSMonk/hegel

Answer questions vkurchatkin

That is a separate issue. Refinement is still incorrect

useful!

Related questions

No questions were found.
Github User Rank List