Skip to content

Spurious "A type predicate's type must be assignable to its parameter's type" #21185

@pelotom

Description

@pelotom

TypeScript Version: 2.7.0-dev.20180113

Code

This type operator from the Unionize library:

type Predicates<TaggedRecord> = {
  [T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T]
}

Expected behavior:

Should compile, and does in [email protected].

Actual behavior:

Fails to compile in typescript@next with

A type predicate's type must be assignable to its parameter's type.
  Type 'TaggedRecord[T]' is not assignable to type 'TaggedRecord[keyof TaggedRecord]'.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions