From 38a0346899e6206788ff47adb9d9b51064ce0645 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 2 Jul 2018 17:50:52 -1000 Subject: [PATCH] Accept new baselines --- .../restTuplesFromContextualTypes.js | 288 +++++++++++++ .../restTuplesFromContextualTypes.symbols | 267 ++++++++++++ .../restTuplesFromContextualTypes.types | 394 ++++++++++++++++++ 3 files changed, 949 insertions(+) create mode 100644 tests/baselines/reference/restTuplesFromContextualTypes.js create mode 100644 tests/baselines/reference/restTuplesFromContextualTypes.symbols create mode 100644 tests/baselines/reference/restTuplesFromContextualTypes.types diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.js b/tests/baselines/reference/restTuplesFromContextualTypes.js new file mode 100644 index 0000000000..3db6c53f38 --- /dev/null +++ b/tests/baselines/reference/restTuplesFromContextualTypes.js @@ -0,0 +1,288 @@ +//// [restTuplesFromContextualTypes.ts] +declare const t1: [number, boolean, string]; + +(function (a, b, c){})(...t1); +(function (...x){})(...t1); +(function (a, ...x){})(...t1); +(function (a, b, ...x){})(...t1); +(function (a, b, c, ...x){})(...t1); + +declare function f1(cb: (...args: typeof t1) => void): void; + +f1((a, b, c) => {}) +f1((...x) => {}) +f1((a, ...x) => {}) +f1((a, b, ...x) => {}) +f1((a, b, c, ...x) => {}) + +declare const t2: [number, boolean, ...string[]]; + +(function (a, b, c){})(...t2); +(function (...x){})(...t2); +(function (a, ...x){})(...t2); +(function (a, b, ...x){})(...t2); +(function (a, b, c, ...x){})(...t2); + +declare function f2(cb: (...args: typeof t2) => void): void; + +f2((a, b, c) => {}) +f2((...x) => {}) +f2((a, ...x) => {}) +f2((a, b, ...x) => {}) +f2((a, b, c, ...x) => {}) + +declare const t3: [boolean, ...string[]]; + +(function (a, b, c){})(1, ...t3); +(function (...x){})(1, ...t3); +(function (a, ...x){})(1, ...t3); +(function (a, b, ...x){})(1, ...t3); +(function (a, b, c, ...x){})(1, ...t3); + +declare function f3(cb: (x: number, ...args: typeof t3) => void): void; + +f3((a, b, c) => {}) +f3((...x) => {}) +f3((a, ...x) => {}) +f3((a, b, ...x) => {}) +f3((a, b, c, ...x) => {}) + +function f4(t: T) { + (function(...x){})(...t); + (function(a, ...x){})(1, ...t); + (function(a, ...x){})(1, 2, ...t); + function f(cb: (x: number, ...args: T) => void) {} + f((...x) => {}); + f((a, ...x) => {}); + f((a, b, ...x) => {}); +} + +// Repro from #25288 + +declare var tuple: [number, string]; +(function foo(a, b){}(...tuple)); + +// Repro from #25289 + +declare function take(cb: (a: number, b: string) => void): void; + +(function foo(...rest){}(1, '')); +take(function(...rest){}); + + +//// [restTuplesFromContextualTypes.js] +"use strict"; +(function (a, b, c) { }).apply(void 0, t1); +(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}).apply(void 0, t1); +(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}).apply(void 0, t1); +(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}).apply(void 0, t1); +(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}).apply(void 0, t1); +f1(function (a, b, c) { }); +f1(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}); +f1(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}); +f1(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}); +f1(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}); +(function (a, b, c) { }).apply(void 0, t2); +(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}).apply(void 0, t2); +(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}).apply(void 0, t2); +(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}).apply(void 0, t2); +(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}).apply(void 0, t2); +f2(function (a, b, c) { }); +f2(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}); +f2(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}); +f2(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}); +f2(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}); +(function (a, b, c) { }).apply(void 0, [1].concat(t3)); +(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}).apply(void 0, [1].concat(t3)); +(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}).apply(void 0, [1].concat(t3)); +(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}).apply(void 0, [1].concat(t3)); +(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}).apply(void 0, [1].concat(t3)); +f3(function (a, b, c) { }); +f3(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +}); +f3(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } +}); +f3(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } +}); +f3(function (a, b, c) { + var x = []; + for (var _i = 3; _i < arguments.length; _i++) { + x[_i - 3] = arguments[_i]; + } +}); +function f4(t) { + (function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } + }).apply(void 0, t); + (function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } + }).apply(void 0, [1].concat(t)); + (function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } + }).apply(void 0, [1, 2].concat(t)); + function f(cb) { } + f(function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } + }); + f(function (a) { + var x = []; + for (var _i = 1; _i < arguments.length; _i++) { + x[_i - 1] = arguments[_i]; + } + }); + f(function (a, b) { + var x = []; + for (var _i = 2; _i < arguments.length; _i++) { + x[_i - 2] = arguments[_i]; + } + }); +} +(function foo(a, b) { }.apply(void 0, tuple)); +(function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i] = arguments[_i]; + } +}(1, '')); +take(function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i] = arguments[_i]; + } +}); + + +//// [restTuplesFromContextualTypes.d.ts] +declare const t1: [number, boolean, string]; +declare function f1(cb: (...args: typeof t1) => void): void; +declare const t2: [number, boolean, ...string[]]; +declare function f2(cb: (...args: typeof t2) => void): void; +declare const t3: [boolean, ...string[]]; +declare function f3(cb: (x: number, ...args: typeof t3) => void): void; +declare function f4(t: T): void; +declare var tuple: [number, string]; +declare function take(cb: (a: number, b: string) => void): void; diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.symbols b/tests/baselines/reference/restTuplesFromContextualTypes.symbols new file mode 100644 index 0000000000..d9b2310b5e --- /dev/null +++ b/tests/baselines/reference/restTuplesFromContextualTypes.symbols @@ -0,0 +1,267 @@ +=== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts === +declare const t1: [number, boolean, string]; +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +(function (a, b, c){})(...t1); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 2, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 2, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 2, 16)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +(function (...x){})(...t1); +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 3, 11)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +(function (a, ...x){})(...t1); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 4, 11)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 4, 13)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +(function (a, b, ...x){})(...t1); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 5, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 5, 13)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 5, 16)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +(function (a, b, c, ...x){})(...t1); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 6, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 6, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 6, 16)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 6, 19)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +declare function f1(cb: (...args: typeof t1) => void): void; +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>cb : Symbol(cb, Decl(restTuplesFromContextualTypes.ts, 8, 20)) +>args : Symbol(args, Decl(restTuplesFromContextualTypes.ts, 8, 25)) +>t1 : Symbol(t1, Decl(restTuplesFromContextualTypes.ts, 0, 13)) + +f1((a, b, c) => {}) +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 10, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 10, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 10, 9)) + +f1((...x) => {}) +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 11, 4)) + +f1((a, ...x) => {}) +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 12, 4)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 12, 6)) + +f1((a, b, ...x) => {}) +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 13, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 13, 6)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 13, 9)) + +f1((a, b, c, ...x) => {}) +>f1 : Symbol(f1, Decl(restTuplesFromContextualTypes.ts, 6, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 14, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 14, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 14, 9)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 14, 12)) + +declare const t2: [number, boolean, ...string[]]; +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +(function (a, b, c){})(...t2); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 18, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 18, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 18, 16)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +(function (...x){})(...t2); +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 19, 11)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +(function (a, ...x){})(...t2); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 20, 11)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 20, 13)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +(function (a, b, ...x){})(...t2); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 21, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 21, 13)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 21, 16)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +(function (a, b, c, ...x){})(...t2); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 22, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 22, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 22, 16)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 22, 19)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +declare function f2(cb: (...args: typeof t2) => void): void; +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>cb : Symbol(cb, Decl(restTuplesFromContextualTypes.ts, 24, 20)) +>args : Symbol(args, Decl(restTuplesFromContextualTypes.ts, 24, 25)) +>t2 : Symbol(t2, Decl(restTuplesFromContextualTypes.ts, 16, 13)) + +f2((a, b, c) => {}) +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 26, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 26, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 26, 9)) + +f2((...x) => {}) +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 27, 4)) + +f2((a, ...x) => {}) +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 28, 4)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 28, 6)) + +f2((a, b, ...x) => {}) +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 29, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 29, 6)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 29, 9)) + +f2((a, b, c, ...x) => {}) +>f2 : Symbol(f2, Decl(restTuplesFromContextualTypes.ts, 22, 36)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 30, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 30, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 30, 9)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 30, 12)) + +declare const t3: [boolean, ...string[]]; +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +(function (a, b, c){})(1, ...t3); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 34, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 34, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 34, 16)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +(function (...x){})(1, ...t3); +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 35, 11)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +(function (a, ...x){})(1, ...t3); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 36, 11)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 36, 13)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +(function (a, b, ...x){})(1, ...t3); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 37, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 37, 13)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 37, 16)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +(function (a, b, c, ...x){})(1, ...t3); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 38, 11)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 38, 13)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 38, 16)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 38, 19)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +declare function f3(cb: (x: number, ...args: typeof t3) => void): void; +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>cb : Symbol(cb, Decl(restTuplesFromContextualTypes.ts, 40, 20)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 40, 25)) +>args : Symbol(args, Decl(restTuplesFromContextualTypes.ts, 40, 35)) +>t3 : Symbol(t3, Decl(restTuplesFromContextualTypes.ts, 32, 13)) + +f3((a, b, c) => {}) +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 42, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 42, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 42, 9)) + +f3((...x) => {}) +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 43, 4)) + +f3((a, ...x) => {}) +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 44, 4)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 44, 6)) + +f3((a, b, ...x) => {}) +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 45, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 45, 6)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 45, 9)) + +f3((a, b, c, ...x) => {}) +>f3 : Symbol(f3, Decl(restTuplesFromContextualTypes.ts, 38, 39)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 46, 4)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 46, 6)) +>c : Symbol(c, Decl(restTuplesFromContextualTypes.ts, 46, 9)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 46, 12)) + +function f4(t: T) { +>f4 : Symbol(f4, Decl(restTuplesFromContextualTypes.ts, 46, 25)) +>T : Symbol(T, Decl(restTuplesFromContextualTypes.ts, 48, 12)) +>t : Symbol(t, Decl(restTuplesFromContextualTypes.ts, 48, 29)) +>T : Symbol(T, Decl(restTuplesFromContextualTypes.ts, 48, 12)) + + (function(...x){})(...t); +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 49, 14)) +>t : Symbol(t, Decl(restTuplesFromContextualTypes.ts, 48, 29)) + + (function(a, ...x){})(1, ...t); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 50, 14)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 50, 16)) +>t : Symbol(t, Decl(restTuplesFromContextualTypes.ts, 48, 29)) + + (function(a, ...x){})(1, 2, ...t); +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 51, 14)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 51, 16)) +>t : Symbol(t, Decl(restTuplesFromContextualTypes.ts, 48, 29)) + + function f(cb: (x: number, ...args: T) => void) {} +>f : Symbol(f, Decl(restTuplesFromContextualTypes.ts, 51, 38)) +>cb : Symbol(cb, Decl(restTuplesFromContextualTypes.ts, 52, 15)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 52, 20)) +>args : Symbol(args, Decl(restTuplesFromContextualTypes.ts, 52, 30)) +>T : Symbol(T, Decl(restTuplesFromContextualTypes.ts, 48, 12)) + + f((...x) => {}); +>f : Symbol(f, Decl(restTuplesFromContextualTypes.ts, 51, 38)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 53, 7)) + + f((a, ...x) => {}); +>f : Symbol(f, Decl(restTuplesFromContextualTypes.ts, 51, 38)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 54, 7)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 54, 9)) + + f((a, b, ...x) => {}); +>f : Symbol(f, Decl(restTuplesFromContextualTypes.ts, 51, 38)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 55, 7)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 55, 9)) +>x : Symbol(x, Decl(restTuplesFromContextualTypes.ts, 55, 12)) +} + +// Repro from #25288 + +declare var tuple: [number, string]; +>tuple : Symbol(tuple, Decl(restTuplesFromContextualTypes.ts, 60, 11)) + +(function foo(a, b){}(...tuple)); +>foo : Symbol(foo, Decl(restTuplesFromContextualTypes.ts, 61, 1)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 61, 14)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 61, 16)) +>tuple : Symbol(tuple, Decl(restTuplesFromContextualTypes.ts, 60, 11)) + +// Repro from #25289 + +declare function take(cb: (a: number, b: string) => void): void; +>take : Symbol(take, Decl(restTuplesFromContextualTypes.ts, 61, 33)) +>cb : Symbol(cb, Decl(restTuplesFromContextualTypes.ts, 65, 22)) +>a : Symbol(a, Decl(restTuplesFromContextualTypes.ts, 65, 27)) +>b : Symbol(b, Decl(restTuplesFromContextualTypes.ts, 65, 37)) + +(function foo(...rest){}(1, '')); +>foo : Symbol(foo, Decl(restTuplesFromContextualTypes.ts, 67, 1)) +>rest : Symbol(rest, Decl(restTuplesFromContextualTypes.ts, 67, 14)) + +take(function(...rest){}); +>take : Symbol(take, Decl(restTuplesFromContextualTypes.ts, 61, 33)) +>rest : Symbol(rest, Decl(restTuplesFromContextualTypes.ts, 68, 14)) + diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types new file mode 100644 index 0000000000..49824b2fb6 --- /dev/null +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -0,0 +1,394 @@ +=== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts === +declare const t1: [number, boolean, string]; +>t1 : [number, boolean, string] + +(function (a, b, c){})(...t1); +>(function (a, b, c){})(...t1) : void +>(function (a, b, c){}) : (a: number, b?: boolean, c?: string) => void +>function (a, b, c){} : (a: number, b?: boolean, c?: string) => void +>a : number +>b : boolean +>c : string +>...t1 : string | number | boolean +>t1 : [number, boolean, string] + +(function (...x){})(...t1); +>(function (...x){})(...t1) : void +>(function (...x){}) : (x_0: number, x_1: boolean, x_2: string) => void +>function (...x){} : (x_0: number, x_1: boolean, x_2: string) => void +>x : [number, boolean, string] +>...t1 : string | number | boolean +>t1 : [number, boolean, string] + +(function (a, ...x){})(...t1); +>(function (a, ...x){})(...t1) : void +>(function (a, ...x){}) : (a: number, x_0: boolean, x_1: string) => void +>function (a, ...x){} : (a: number, x_0: boolean, x_1: string) => void +>a : number +>x : [boolean, string] +>...t1 : string | number | boolean +>t1 : [number, boolean, string] + +(function (a, b, ...x){})(...t1); +>(function (a, b, ...x){})(...t1) : void +>(function (a, b, ...x){}) : (a: number, b?: boolean, x_0: string) => void +>function (a, b, ...x){} : (a: number, b?: boolean, x_0: string) => void +>a : number +>b : boolean +>x : [string] +>...t1 : string | number | boolean +>t1 : [number, boolean, string] + +(function (a, b, c, ...x){})(...t1); +>(function (a, b, c, ...x){})(...t1) : void +>(function (a, b, c, ...x){}) : (a: number, b?: boolean, c?: string) => void +>function (a, b, c, ...x){} : (a: number, b?: boolean, c?: string) => void +>a : number +>b : boolean +>c : string +>x : [] +>...t1 : string | number | boolean +>t1 : [number, boolean, string] + +declare function f1(cb: (...args: typeof t1) => void): void; +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>cb : (args_0: number, args_1: boolean, args_2: string) => void +>args : [number, boolean, string] +>t1 : [number, boolean, string] + +f1((a, b, c) => {}) +>f1((a, b, c) => {}) : void +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>(a, b, c) => {} : (a: number, b: boolean, c: string) => void +>a : number +>b : boolean +>c : string + +f1((...x) => {}) +>f1((...x) => {}) : void +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>(...x) => {} : (args_0: number, args_1: boolean, args_2: string) => void +>x : [number, boolean, string] + +f1((a, ...x) => {}) +>f1((a, ...x) => {}) : void +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>(a, ...x) => {} : (a: number, args_1: boolean, args_2: string) => void +>a : number +>x : [boolean, string] + +f1((a, b, ...x) => {}) +>f1((a, b, ...x) => {}) : void +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>(a, b, ...x) => {} : (a: number, b: boolean, args_2: string) => void +>a : number +>b : boolean +>x : [string] + +f1((a, b, c, ...x) => {}) +>f1((a, b, c, ...x) => {}) : void +>f1 : (cb: (args_0: number, args_1: boolean, args_2: string) => void) => void +>(a, b, c, ...x) => {} : (a: number, b: boolean, c: string) => void +>a : number +>b : boolean +>c : string +>x : [] + +declare const t2: [number, boolean, ...string[]]; +>t2 : [number, boolean, ...string[]] + +(function (a, b, c){})(...t2); +>(function (a, b, c){})(...t2) : void +>(function (a, b, c){}) : (a: number, b?: boolean, c?: string) => void +>function (a, b, c){} : (a: number, b?: boolean, c?: string) => void +>a : number +>b : boolean +>c : string +>...t2 : string | number | boolean +>t2 : [number, boolean, ...string[]] + +(function (...x){})(...t2); +>(function (...x){})(...t2) : void +>(function (...x){}) : (x_0: number, x_1: boolean, ...x_2: string[]) => void +>function (...x){} : (x_0: number, x_1: boolean, ...x_2: string[]) => void +>x : [number, boolean, ...string[]] +>...t2 : string | number | boolean +>t2 : [number, boolean, ...string[]] + +(function (a, ...x){})(...t2); +>(function (a, ...x){})(...t2) : void +>(function (a, ...x){}) : (a: number, x_0: boolean, ...x_1: string[]) => void +>function (a, ...x){} : (a: number, x_0: boolean, ...x_1: string[]) => void +>a : number +>x : [boolean, ...string[]] +>...t2 : string | number | boolean +>t2 : [number, boolean, ...string[]] + +(function (a, b, ...x){})(...t2); +>(function (a, b, ...x){})(...t2) : void +>(function (a, b, ...x){}) : (a: number, b?: boolean, ...x: string[]) => void +>function (a, b, ...x){} : (a: number, b?: boolean, ...x: string[]) => void +>a : number +>b : boolean +>x : string[] +>...t2 : string | number | boolean +>t2 : [number, boolean, ...string[]] + +(function (a, b, c, ...x){})(...t2); +>(function (a, b, c, ...x){})(...t2) : void +>(function (a, b, c, ...x){}) : (a: number, b?: boolean, c?: string, ...x: string[]) => void +>function (a, b, c, ...x){} : (a: number, b?: boolean, c?: string, ...x: string[]) => void +>a : number +>b : boolean +>c : string +>x : string[] +>...t2 : string | number | boolean +>t2 : [number, boolean, ...string[]] + +declare function f2(cb: (...args: typeof t2) => void): void; +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>cb : (args_0: number, args_1: boolean, ...args_2: string[]) => void +>args : [number, boolean, ...string[]] +>t2 : [number, boolean, ...string[]] + +f2((a, b, c) => {}) +>f2((a, b, c) => {}) : void +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>(a, b, c) => {} : (a: number, b: boolean, c: string) => void +>a : number +>b : boolean +>c : string + +f2((...x) => {}) +>f2((...x) => {}) : void +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>(...x) => {} : (args_0: number, args_1: boolean, ...args_2: string[]) => void +>x : [number, boolean, ...string[]] + +f2((a, ...x) => {}) +>f2((a, ...x) => {}) : void +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>(a, ...x) => {} : (a: number, args_1: boolean, ...args_2: string[]) => void +>a : number +>x : [boolean, ...string[]] + +f2((a, b, ...x) => {}) +>f2((a, b, ...x) => {}) : void +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>(a, b, ...x) => {} : (a: number, b: boolean, ...x: string[]) => void +>a : number +>b : boolean +>x : string[] + +f2((a, b, c, ...x) => {}) +>f2((a, b, c, ...x) => {}) : void +>f2 : (cb: (args_0: number, args_1: boolean, ...args_2: string[]) => void) => void +>(a, b, c, ...x) => {} : (a: number, b: boolean, c: string, ...x: string[]) => void +>a : number +>b : boolean +>c : string +>x : string[] + +declare const t3: [boolean, ...string[]]; +>t3 : [boolean, ...string[]] + +(function (a, b, c){})(1, ...t3); +>(function (a, b, c){})(1, ...t3) : void +>(function (a, b, c){}) : (a: number, b: boolean, c?: string) => void +>function (a, b, c){} : (a: number, b: boolean, c?: string) => void +>a : number +>b : boolean +>c : string +>1 : 1 +>...t3 : string | boolean +>t3 : [boolean, ...string[]] + +(function (...x){})(1, ...t3); +>(function (...x){})(1, ...t3) : void +>(function (...x){}) : (x_0: number, x_1: boolean, ...x_2: string[]) => void +>function (...x){} : (x_0: number, x_1: boolean, ...x_2: string[]) => void +>x : [number, boolean, ...string[]] +>1 : 1 +>...t3 : string | boolean +>t3 : [boolean, ...string[]] + +(function (a, ...x){})(1, ...t3); +>(function (a, ...x){})(1, ...t3) : void +>(function (a, ...x){}) : (a: number, x_0: boolean, ...x_1: string[]) => void +>function (a, ...x){} : (a: number, x_0: boolean, ...x_1: string[]) => void +>a : number +>x : [boolean, ...string[]] +>1 : 1 +>...t3 : string | boolean +>t3 : [boolean, ...string[]] + +(function (a, b, ...x){})(1, ...t3); +>(function (a, b, ...x){})(1, ...t3) : void +>(function (a, b, ...x){}) : (a: number, b: boolean, ...x: string[]) => void +>function (a, b, ...x){} : (a: number, b: boolean, ...x: string[]) => void +>a : number +>b : boolean +>x : string[] +>1 : 1 +>...t3 : string | boolean +>t3 : [boolean, ...string[]] + +(function (a, b, c, ...x){})(1, ...t3); +>(function (a, b, c, ...x){})(1, ...t3) : void +>(function (a, b, c, ...x){}) : (a: number, b: boolean, c?: string, ...x: string[]) => void +>function (a, b, c, ...x){} : (a: number, b: boolean, c?: string, ...x: string[]) => void +>a : number +>b : boolean +>c : string +>x : string[] +>1 : 1 +>...t3 : string | boolean +>t3 : [boolean, ...string[]] + +declare function f3(cb: (x: number, ...args: typeof t3) => void): void; +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>cb : (x: number, args_0: boolean, ...args_1: string[]) => void +>x : number +>args : [boolean, ...string[]] +>t3 : [boolean, ...string[]] + +f3((a, b, c) => {}) +>f3((a, b, c) => {}) : void +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>(a, b, c) => {} : (a: number, b: boolean, c: string) => void +>a : number +>b : boolean +>c : string + +f3((...x) => {}) +>f3((...x) => {}) : void +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>(...x) => {} : (x: number, args_0: boolean, ...args_1: string[]) => void +>x : [number, boolean, ...string[]] + +f3((a, ...x) => {}) +>f3((a, ...x) => {}) : void +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>(a, ...x) => {} : (a: number, args_0: boolean, ...args_1: string[]) => void +>a : number +>x : [boolean, ...string[]] + +f3((a, b, ...x) => {}) +>f3((a, b, ...x) => {}) : void +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>(a, b, ...x) => {} : (a: number, b: boolean, ...x: string[]) => void +>a : number +>b : boolean +>x : string[] + +f3((a, b, c, ...x) => {}) +>f3((a, b, c, ...x) => {}) : void +>f3 : (cb: (x: number, args_0: boolean, ...args_1: string[]) => void) => void +>(a, b, c, ...x) => {} : (a: number, b: boolean, c: string, ...x: string[]) => void +>a : number +>b : boolean +>c : string +>x : string[] + +function f4(t: T) { +>f4 : (t: T) => void +>T : T +>t : T +>T : T + + (function(...x){})(...t); +>(function(...x){})(...t) : void +>(function(...x){}) : (...x: T) => void +>function(...x){} : (...x: T) => void +>x : T +>...t : any +>t : T + + (function(a, ...x){})(1, ...t); +>(function(a, ...x){})(1, ...t) : void +>(function(a, ...x){}) : (a: number, ...x: T) => void +>function(a, ...x){} : (a: number, ...x: T) => void +>a : number +>x : T +>1 : 1 +>...t : any +>t : T + + (function(a, ...x){})(1, 2, ...t); +>(function(a, ...x){})(1, 2, ...t) : void +>(function(a, ...x){}) : (a: number, x_0: number, ...x_1: any[]) => void +>function(a, ...x){} : (a: number, x_0: number, ...x_1: any[]) => void +>a : number +>x : [number, ...any[]] +>1 : 1 +>2 : 2 +>...t : any +>t : T + + function f(cb: (x: number, ...args: T) => void) {} +>f : (cb: (x: number, ...args: T) => void) => void +>cb : (x: number, ...args: T) => void +>x : number +>args : T +>T : T + + f((...x) => {}); +>f((...x) => {}) : void +>f : (cb: (x: number, ...args: T) => void) => void +>(...x) => {} : (x: number, ...args: any[]) => void +>x : [number, ...any[]] + + f((a, ...x) => {}); +>f((a, ...x) => {}) : void +>f : (cb: (x: number, ...args: T) => void) => void +>(a, ...x) => {} : (a: number, ...x: T) => void +>a : number +>x : T + + f((a, b, ...x) => {}); +>f((a, b, ...x) => {}) : void +>f : (cb: (x: number, ...args: T) => void) => void +>(a, b, ...x) => {} : (a: number, b: any, ...x: any[]) => void +>a : number +>b : any +>x : any[] +} + +// Repro from #25288 + +declare var tuple: [number, string]; +>tuple : [number, string] + +(function foo(a, b){}(...tuple)); +>(function foo(a, b){}(...tuple)) : void +>function foo(a, b){}(...tuple) : void +>function foo(a, b){} : (a: number, b?: string) => void +>foo : (a: number, b?: string) => void +>a : number +>b : string +>...tuple : string | number +>tuple : [number, string] + +// Repro from #25289 + +declare function take(cb: (a: number, b: string) => void): void; +>take : (cb: (a: number, b: string) => void) => void +>cb : (a: number, b: string) => void +>a : number +>b : string + +(function foo(...rest){}(1, '')); +>(function foo(...rest){}(1, '')) : void +>function foo(...rest){}(1, '') : void +>function foo(...rest){} : (rest_0: number, rest_1: string) => void +>foo : (rest_0: number, rest_1: string) => void +>rest : [number, string] +>1 : 1 +>'' : "" + +take(function(...rest){}); +>take(function(...rest){}) : void +>take : (cb: (a: number, b: string) => void) => void +>function(...rest){} : (a: number, b: string) => void +>rest : [number, string] +