Skip to content

in keyword doesn't narrow types with string-indexers correctly #20540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sandersn opened this issue Dec 7, 2017 · 1 comment
Closed

in keyword doesn't narrow types with string-indexers correctly #20540

sandersn opened this issue Dec 7, 2017 · 1 comment
Assignees
Labels
Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

sandersn commented Dec 7, 2017

This is broken in the new narrowing for the in keyword (#15256).
The test inKeywordTypeguard needs to add the following test:

interface StringMap<T> {
  [key: string]: T
}
function f(options: StringMap<any>) {
  if ('data' in options) {
    return options['data'];
  }
}

Right now there is an error on options['data'], but there shouldn't be.

@sandersn
Copy link
Member Author

sandersn commented Dec 7, 2017

Fix is up at #20543

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 11, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants