Skip to content

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

Closed
@sandersn

Description

@sandersn

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.

Metadata

Metadata

Assignees

Labels

FixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions