Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Incorrect refinement using instanceof #230

Closed
vkurchatkin opened this issue May 21, 2020 · 3 comments
Closed

Incorrect refinement using instanceof #230

vkurchatkin opened this issue May 21, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@vkurchatkin
Copy link

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.

@thecotne
Copy link
Contributor

you should not be able to extend class and change signature/type of existing functions

both typescript and flow do this

try typescript
try flow

@vkurchatkin
Copy link
Author

That is a separate issue. Refinement is still incorrect

@JSMonk JSMonk added the bug Something isn't working label May 21, 2020
@JSMonk
Copy link
Owner

JSMonk commented Jun 10, 2020

Fixed in 0.0.44

@JSMonk JSMonk closed this as completed Jun 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants