diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 1aef3a3bc99..c47cc649498 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -119,6 +119,27 @@ let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } // non primitive let spreadNonPrimitive = { ...{}}; + +// generic spreads +function genericSpread(t: T, u: U, v: T | U, w: T | { s: string }, obj: { x: number }) { + let x01 = { ...t }; + let x02 = { ...t, ...t }; + let x03 = { ...t, ...u }; + let x04 = { ...u, ...t }; + let x05 = { a: 5, b: 'hi', ...t }; + let x06 = { ...t, a: 5, b: 'hi' }; + let x07 = { a: 5, b: 'hi', ...t, c: true, ...obj }; + let x09 = { a: 5, ...t, b: 'hi', c: true, ...obj }; + let x10 = { a: 5, ...t, b: 'hi', ...u, ...obj }; + let x11 = { ...v }; + let x12 = { ...v, ...obj }; + let x13 = { ...w }; + let x14 = { ...w, ...obj }; + let x15 = { ...t, ...v }; + let x16 = { ...t, ...w }; + let x17 = { ...t, ...w, ...obj }; + let x18 = { ...t, ...v, ...w }; +} //// [objectSpread.js] @@ -214,3 +235,23 @@ var a = 12; var shortCutted = __assign({}, o, { a: a }); // non primitive var spreadNonPrimitive = __assign({}, {}); +// generic spreads +function genericSpread(t, u, v, w, obj) { + var x01 = __assign({}, t); + var x02 = __assign({}, t, t); + var x03 = __assign({}, t, u); + var x04 = __assign({}, u, t); + var x05 = __assign({ a: 5, b: 'hi' }, t); + var x06 = __assign({}, t, { a: 5, b: 'hi' }); + var x07 = __assign({ a: 5, b: 'hi' }, t, { c: true }, obj); + var x09 = __assign({ a: 5 }, t, { b: 'hi', c: true }, obj); + var x10 = __assign({ a: 5 }, t, { b: 'hi' }, u, obj); + var x11 = __assign({}, v); + var x12 = __assign({}, v, obj); + var x13 = __assign({}, w); + var x14 = __assign({}, w, obj); + var x15 = __assign({}, t, v); + var x16 = __assign({}, t, w); + var x17 = __assign({}, t, w, obj); + var x18 = __assign({}, t, v, w); +} diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 0bbcd4a9f4b..6702ff5c909 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -452,3 +452,117 @@ let shortCutted: { a: number, b: string } = { ...o, a } let spreadNonPrimitive = { ...{}}; >spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 119, 3)) +// generic spreads +function genericSpread(t: T, u: U, v: T | U, w: T | { s: string }, obj: { x: number }) { +>genericSpread : Symbol(genericSpread, Decl(objectSpread.ts, 119, 42)) +>T : Symbol(T, Decl(objectSpread.ts, 122, 23)) +>U : Symbol(U, Decl(objectSpread.ts, 122, 25)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>T : Symbol(T, Decl(objectSpread.ts, 122, 23)) +>u : Symbol(u, Decl(objectSpread.ts, 122, 34)) +>U : Symbol(U, Decl(objectSpread.ts, 122, 25)) +>v : Symbol(v, Decl(objectSpread.ts, 122, 40)) +>T : Symbol(T, Decl(objectSpread.ts, 122, 23)) +>U : Symbol(U, Decl(objectSpread.ts, 122, 25)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) +>T : Symbol(T, Decl(objectSpread.ts, 122, 23)) +>s : Symbol(s, Decl(objectSpread.ts, 122, 59)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) +>x : Symbol(x, Decl(objectSpread.ts, 122, 79)) + + let x01 = { ...t }; +>x01 : Symbol(x01, Decl(objectSpread.ts, 123, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) + + let x02 = { ...t, ...t }; +>x02 : Symbol(x02, Decl(objectSpread.ts, 124, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) + + let x03 = { ...t, ...u }; +>x03 : Symbol(x03, Decl(objectSpread.ts, 125, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>u : Symbol(u, Decl(objectSpread.ts, 122, 34)) + + let x04 = { ...u, ...t }; +>x04 : Symbol(x04, Decl(objectSpread.ts, 126, 7)) +>u : Symbol(u, Decl(objectSpread.ts, 122, 34)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) + + let x05 = { a: 5, b: 'hi', ...t }; +>x05 : Symbol(x05, Decl(objectSpread.ts, 127, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 127, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 127, 21)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) + + let x06 = { ...t, a: 5, b: 'hi' }; +>x06 : Symbol(x06, Decl(objectSpread.ts, 128, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>a : Symbol(a, Decl(objectSpread.ts, 128, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 128, 27)) + + let x07 = { a: 5, b: 'hi', ...t, c: true, ...obj }; +>x07 : Symbol(x07, Decl(objectSpread.ts, 129, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 129, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 129, 21)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>c : Symbol(c, Decl(objectSpread.ts, 129, 36)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x09 = { a: 5, ...t, b: 'hi', c: true, ...obj }; +>x09 : Symbol(x09, Decl(objectSpread.ts, 130, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 130, 15)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>b : Symbol(b, Decl(objectSpread.ts, 130, 27)) +>c : Symbol(c, Decl(objectSpread.ts, 130, 36)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x10 = { a: 5, ...t, b: 'hi', ...u, ...obj }; +>x10 : Symbol(x10, Decl(objectSpread.ts, 131, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 131, 15)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>b : Symbol(b, Decl(objectSpread.ts, 131, 27)) +>u : Symbol(u, Decl(objectSpread.ts, 122, 34)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x11 = { ...v }; +>x11 : Symbol(x11, Decl(objectSpread.ts, 132, 7)) +>v : Symbol(v, Decl(objectSpread.ts, 122, 40)) + + let x12 = { ...v, ...obj }; +>x12 : Symbol(x12, Decl(objectSpread.ts, 133, 7)) +>v : Symbol(v, Decl(objectSpread.ts, 122, 40)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x13 = { ...w }; +>x13 : Symbol(x13, Decl(objectSpread.ts, 134, 7)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) + + let x14 = { ...w, ...obj }; +>x14 : Symbol(x14, Decl(objectSpread.ts, 135, 7)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x15 = { ...t, ...v }; +>x15 : Symbol(x15, Decl(objectSpread.ts, 136, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>v : Symbol(v, Decl(objectSpread.ts, 122, 40)) + + let x16 = { ...t, ...w }; +>x16 : Symbol(x16, Decl(objectSpread.ts, 137, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) + + let x17 = { ...t, ...w, ...obj }; +>x17 : Symbol(x17, Decl(objectSpread.ts, 138, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) +>obj : Symbol(obj, Decl(objectSpread.ts, 122, 72)) + + let x18 = { ...t, ...v, ...w }; +>x18 : Symbol(x18, Decl(objectSpread.ts, 139, 7)) +>t : Symbol(t, Decl(objectSpread.ts, 122, 29)) +>v : Symbol(v, Decl(objectSpread.ts, 122, 40)) +>w : Symbol(w, Decl(objectSpread.ts, 122, 50)) +} + diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index fc60b0d88cf..8df457a162d 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -578,3 +578,139 @@ let spreadNonPrimitive = { ...{}}; >{} : object >{} : {} +// generic spreads +function genericSpread(t: T, u: U, v: T | U, w: T | { s: string }, obj: { x: number }) { +>genericSpread : (t: T, u: U, v: T | U, w: T | { s: string; }, obj: { x: number; }) => void +>t : T +>u : U +>v : T | U +>w : T | { s: string; } +>s : string +>obj : { x: number; } +>x : number + + let x01 = { ...t }; +>x01 : T +>{ ...t } : T +>t : T + + let x02 = { ...t, ...t }; +>x02 : T +>{ ...t, ...t } : T +>t : T +>t : T + + let x03 = { ...t, ...u }; +>x03 : T & U +>{ ...t, ...u } : T & U +>t : T +>u : U + + let x04 = { ...u, ...t }; +>x04 : U & T +>{ ...u, ...t } : U & T +>u : U +>t : T + + let x05 = { a: 5, b: 'hi', ...t }; +>x05 : { a: number; b: string; } & T +>{ a: 5, b: 'hi', ...t } : { a: number; b: string; } & T +>a : number +>5 : 5 +>b : string +>'hi' : "hi" +>t : T + + let x06 = { ...t, a: 5, b: 'hi' }; +>x06 : T & { a: number; b: string; } +>{ ...t, a: 5, b: 'hi' } : T & { a: number; b: string; } +>t : T +>a : number +>5 : 5 +>b : string +>'hi' : "hi" + + let x07 = { a: 5, b: 'hi', ...t, c: true, ...obj }; +>x07 : { a: number; b: string; } & T & { x: number; c: boolean; } +>{ a: 5, b: 'hi', ...t, c: true, ...obj } : { a: number; b: string; } & T & { x: number; c: boolean; } +>a : number +>5 : 5 +>b : string +>'hi' : "hi" +>t : T +>c : boolean +>true : true +>obj : { x: number; } + + let x09 = { a: 5, ...t, b: 'hi', c: true, ...obj }; +>x09 : { a: number; } & T & { x: number; b: string; c: boolean; } +>{ a: 5, ...t, b: 'hi', c: true, ...obj } : { a: number; } & T & { x: number; b: string; c: boolean; } +>a : number +>5 : 5 +>t : T +>b : string +>'hi' : "hi" +>c : boolean +>true : true +>obj : { x: number; } + + let x10 = { a: 5, ...t, b: 'hi', ...u, ...obj }; +>x10 : { a: number; } & T & { b: string; } & U & { x: number; } +>{ a: 5, ...t, b: 'hi', ...u, ...obj } : { a: number; } & T & { b: string; } & U & { x: number; } +>a : number +>5 : 5 +>t : T +>b : string +>'hi' : "hi" +>u : U +>obj : { x: number; } + + let x11 = { ...v }; +>x11 : T | U +>{ ...v } : T | U +>v : T | U + + let x12 = { ...v, ...obj }; +>x12 : (T & { x: number; }) | (U & { x: number; }) +>{ ...v, ...obj } : (T & { x: number; }) | (U & { x: number; }) +>v : T | U +>obj : { x: number; } + + let x13 = { ...w }; +>x13 : T | { s: string; } +>{ ...w } : T | { s: string; } +>w : T | { s: string; } + + let x14 = { ...w, ...obj }; +>x14 : (T & { x: number; }) | { x: number; s: string; } +>{ ...w, ...obj } : (T & { x: number; }) | { x: number; s: string; } +>w : T | { s: string; } +>obj : { x: number; } + + let x15 = { ...t, ...v }; +>x15 : T | (T & U) +>{ ...t, ...v } : T | (T & U) +>t : T +>v : T | U + + let x16 = { ...t, ...w }; +>x16 : T | (T & { s: string; }) +>{ ...t, ...w } : T | (T & { s: string; }) +>t : T +>w : T | { s: string; } + + let x17 = { ...t, ...w, ...obj }; +>x17 : (T & { x: number; }) | (T & { x: number; s: string; }) +>{ ...t, ...w, ...obj } : (T & { x: number; }) | (T & { x: number; s: string; }) +>t : T +>w : T | { s: string; } +>obj : { x: number; } + + let x18 = { ...t, ...v, ...w }; +>x18 : T | (T & U) | (T & { s: string; }) | (T & U & { s: string; }) +>{ ...t, ...v, ...w } : T | (T & U) | (T & { s: string; }) | (T & U & { s: string; }) +>t : T +>v : T | U +>w : T | { s: string; } +} +