Skip to content

CFA doesn't work with generic constraint type #30316

Closed
@cevek

Description

@cevek

TypeScript Version: 3.4.0-dev.20190307

Search Terms:

Code

function foo<K extends 'a' | 'b'>(k: K) {
  if (k === 'a') {
     const x: 'a' = k; // Type 'K' is not assignable to type '"a"
  }
}

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions