First always inferred as mixed in [infer First, ...infer Rest]
Author: mwiencekCreated Jun 12, 2025Updated Jun 12, 2025
Labelsbugneeds triage
Flow version: v0.273.1
Expected behavior
type GetFirst = ['a', 'b', 'c'] extends [infer First, ...infer Rest]
? First
: empty;
declare var f: GetFirst;
// this should work
f as 'a';
Actual behavior
Cannot cast
fto string literalabecause mixed [1] is incompatible with string literala[2]. [incompatible-cast]
Strangely, First is inferred fine when only using [infer First, ...], or [...infer Rest] + Rest[0]; see the three examples in the Try-Flow.
Source: facebook/flow