Reflect.has fails to act as type guard (should act same as "in" operator) #30688
Labels
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Experience Enhancement
Noncontroversial enhancements
Suggestion
An idea for TypeScript
Milestone
TypeScript Version: ^3.4.0-dev.20190330
Search Terms:
Reflect.has
in operator
Code
Expected behavior:
Both compile successfully. "in" operator acts as a type guard per #10485. Reflect.has should act the same as "in" operator here.
We'd like to use Reflect.has a lot more and this case holds us back. Thank you!
Actual behavior:
"in" operator line compiles;
Reflect.has
line does not compile. Error:445 Reflect.has(a, "field") ? a.field : 0;
Playground Link:
https://goo.gl/2R4dkS
Related Issues:
#10485
The text was updated successfully, but these errors were encountered: