tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts(20,5): error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'FlatArray'. Type 'unknown' is not assignable to type 'FlatArray'. Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. Type 'FlatArray' is not assignable to type 'FlatArray'. Type 'InnerArr' is not assignable to type 'FlatArray'. Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr) & InnerArr'. Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr'. ==== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts (1 errors) ==== // Repro from #43493 declare const foo: unknown[]; const bar = foo.flatMap(bar => bar as Foo); interface Foo extends Array {} // Repros from comments in #43249 const repro_43249 = (value: unknown) => { if (typeof value !== "string") { throw new Error("No"); } const match = value.match(/anything/) || []; const [, extracted] = match; }; function f(x: FlatArray, y: FlatArray) { x = y; y = x; // Error ~ !!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'FlatArray'. !!! error TS2322: Type 'unknown' is not assignable to type 'FlatArray'. !!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. !!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. !!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray : Arr'. !!! error TS2322: Type 'FlatArray' is not assignable to type 'FlatArray'. !!! error TS2322: Type 'InnerArr' is not assignable to type 'FlatArray'. !!! error TS2322: Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr) & InnerArr'. !!! error TS2322: Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray : InnerArr'. }