Skip to content

Generic type is fully incompatible with conditional type #9305

Open

Description

@mwiencek

Flow version: 0.338.0

Expected behavior

function fn<T extends string>(str: T): void {
    str as (T extends string ? T : T); // works
    str as (T extends number ? T : T); // should work but errors
}

Actual behavior

Cannot cast `str` to `T extends number ? T : T` because `string` [1] is incompatible with `T extends number ? T : T` [2]. [incompatible-type]

I understand this is a very contrived example, but I was trying to come up with a minimal reproduction that demonstrates the issue clearly. We've hit this in real code, and I used something closer to a real example in the Try-Flow below.

  • Link to Try-Flow or Github repo: Try-Flow

Activity

  1. added
    Typing: completeness
    and removed on Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Typing: completenessbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions