TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
ahejlsberg on master
Make no inferences from binding… (compare)
ahejlsberg on fix33448
Remove unnecessary '!' assertion (compare)
instanceof
obj instanceof B
doesn't imply obj instanceof C
at runtime
A
constructor test, it shouldn't narrow in the false
branch. Should still be of type A|B
, imo
instanceof
check
class
from interface
typing-wise
fetch-all-unmapped
is the base "fetch" function and everything else is just a convenience function
myQuery.fetchXxx()
Is how it would be exposed.
@AnyhowStep Yeah so I knew the request for better instanceof
behavior was going to be rejected for backward compat reasons but:
and it was an intentional decision to have a situation that wasn't 100% correct, but where usability outweighed.
I'm not sure I agree with the premise here. Structural typing of classes rarely makes sense in my experience; in almost all cases instanceof
is my preferred method of narrowing with classes and that's 100% undeniably nominal
class A
to be considered the same type as class B
just because they happen to have the same methods