Skip to content

Mapped types intersections are too eagerly resolved #17456

@gcnew

Description

@gcnew

TypeScript Version: nightly (2.5.0-dev.20170727)

Code

type StringContains<S extends string, L extends string> = (
    { [K in S]:      'true' } &
    { [key: string]: 'false' }
  )[L]

type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>

type First<T> = ObjectHasKey<T, '0'> // eagerly resolved as 'false'

Expected behavior:
Type First should be left as an indexing operation.

PS: origin of the issue: gcanti/typelevel-ts#8

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions