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 f to string literal a because mixed [1] is incompatible with string literal a [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.
Flow version: v0.273.1
Expected behavior
Actual behavior
Strangely,
Firstis inferred fine when only using[infer First, ...], or[...infer Rest]+Rest[0]; see the three examples in the Try-Flow.