|
| 1 | +=== tests/cases/compiler/arrayFlat.ts === |
| 2 | +const expected1: string[][] = [[[""]]].flat(); |
| 3 | +>expected1 : Symbol(expected1, Decl(arrayFlat.ts, 0, 5)) |
| 4 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 5 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 6 | + |
| 7 | +const expected2: string[][][] = [[[""]]].flat(0); |
| 8 | +>expected2 : Symbol(expected2, Decl(arrayFlat.ts, 2, 5)) |
| 9 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 10 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 11 | + |
| 12 | +const expected3: string[][] = [[[""]]].flat(1); |
| 13 | +>expected3 : Symbol(expected3, Decl(arrayFlat.ts, 3, 5)) |
| 14 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 15 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 16 | + |
| 17 | +const expected4: string[] = [[[""]]].flat(2); |
| 18 | +>expected4 : Symbol(expected4, Decl(arrayFlat.ts, 4, 5)) |
| 19 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 20 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 21 | + |
| 22 | +const expected5: string[] = [[[""]]].flat(3); |
| 23 | +>expected5 : Symbol(expected5, Decl(arrayFlat.ts, 5, 5)) |
| 24 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 25 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 26 | + |
| 27 | +let [actual6] = [[[""]]].flat(undefined as number); |
| 28 | +>actual6 : Symbol(actual6, Decl(arrayFlat.ts, 7, 5)) |
| 29 | +>[[[""]]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 30 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 31 | +>undefined : Symbol(undefined) |
| 32 | + |
| 33 | +const expected6: string[][] | string[] | string = actual6; |
| 34 | +>expected6 : Symbol(expected6, Decl(arrayFlat.ts, 8, 5)) |
| 35 | +>actual6 : Symbol(actual6, Decl(arrayFlat.ts, 7, 5)) |
| 36 | + |
| 37 | +actual6 = undefined as string[][] | string[] | string; |
| 38 | +>actual6 : Symbol(actual6, Decl(arrayFlat.ts, 7, 5)) |
| 39 | +>undefined : Symbol(undefined) |
| 40 | + |
| 41 | +// #24579 and #29604 |
| 42 | + |
| 43 | +let [actual7] = [[""], [1]].flat(); |
| 44 | +>actual7 : Symbol(actual7, Decl(arrayFlat.ts, 13, 5)) |
| 45 | +>[[""], [1]].flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 46 | +>flat : Symbol(Array.flat, Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --) ... and 1 more) |
| 47 | + |
| 48 | +const expected7: string | number = actual7; |
| 49 | +>expected7 : Symbol(expected7, Decl(arrayFlat.ts, 14, 5)) |
| 50 | +>actual7 : Symbol(actual7, Decl(arrayFlat.ts, 13, 5)) |
| 51 | + |
| 52 | +actual7 = undefined as string | number; |
| 53 | +>actual7 : Symbol(actual7, Decl(arrayFlat.ts, 13, 5)) |
| 54 | +>undefined : Symbol(undefined) |
| 55 | + |
| 56 | +const f: any extends typeof actual7 ? true : false = false; |
| 57 | +>f : Symbol(f, Decl(arrayFlat.ts, 16, 5)) |
| 58 | +>actual7 : Symbol(actual7, Decl(arrayFlat.ts, 13, 5)) |
| 59 | + |
0 commit comments