Type guard not applied based on indexed access with string literal #26232
Labels
Add a Flag
Any problem can be solved by flags, except for the problem of having too many flags
Bug
A bug in TypeScript
Milestone
TypeScript Version: 3.1.0-dev.20180804
Search Terms:
dash, bracket
Code
Very similar to documentation example code, but with a discriminant containing a dash. Likely not because of the dash itself, but because the lookup is using
s['kind-of']
instead ofs.kind
.Expected behavior:
No errors
Actual behavior:
My real world use case is to check type of AWS Cloudwatch event using the
detail-type
field on the event, so can't just change the name to get around the restriction easily.The text was updated successfully, but these errors were encountered: