diff --git a/tests/baselines/reference/objectSpreadIntersection.js b/tests/baselines/reference/objectSpreadIntersection.js index d86b7bfca58..2ec6ad35413 100644 --- a/tests/baselines/reference/objectSpreadIntersection.js +++ b/tests/baselines/reference/objectSpreadIntersection.js @@ -8,10 +8,14 @@ function iteratedUnionIntersection(t: T, u: U, v: V): void { // concrete types work interface A1 { a: number } interface A2 { a: string } +interface B1 { b: number } +interface B2 { b: string } let a12: A1 & A2; -let result = { ...a12 }; +let b12: B1 & B2; +let result = { ...a12, ...b12 }; let sn: number & string = result.a; -let assignable: { ...(A1 & A2) } = result; +sn = result.b; +let assignable: { ...(A1 & A2), ...(B1 & B2) } = result; function tripleIntersection(t: T, u: U, v: V): void { let tuv: T & U & V; @@ -49,8 +53,10 @@ function iteratedUnionIntersection(t, u, v) { var assignable = result; } var a12; -var result = __assign({}, a12); +var b12; +var result = __assign({}, a12, b12); var sn = result.a; +sn = result.b; var assignable = result; function tripleIntersection(t, u, v) { var tuv; diff --git a/tests/baselines/reference/objectSpreadIntersection.symbols b/tests/baselines/reference/objectSpreadIntersection.symbols index 6dd27645ddf..bc63cb11348 100644 --- a/tests/baselines/reference/objectSpreadIntersection.symbols +++ b/tests/baselines/reference/objectSpreadIntersection.symbols @@ -43,125 +43,146 @@ interface A2 { a: string } >A2 : Symbol(A2, Decl(objectSpreadIntersection.ts, 7, 26)) >a : Symbol(A2.a, Decl(objectSpreadIntersection.ts, 8, 14)) +interface B1 { b: number } +>B1 : Symbol(B1, Decl(objectSpreadIntersection.ts, 8, 26)) +>b : Symbol(B1.b, Decl(objectSpreadIntersection.ts, 9, 14)) + +interface B2 { b: string } +>B2 : Symbol(B2, Decl(objectSpreadIntersection.ts, 9, 26)) +>b : Symbol(B2.b, Decl(objectSpreadIntersection.ts, 10, 14)) + let a12: A1 & A2; ->a12 : Symbol(a12, Decl(objectSpreadIntersection.ts, 9, 3)) +>a12 : Symbol(a12, Decl(objectSpreadIntersection.ts, 11, 3)) >A1 : Symbol(A1, Decl(objectSpreadIntersection.ts, 5, 1)) >A2 : Symbol(A2, Decl(objectSpreadIntersection.ts, 7, 26)) -let result = { ...a12 }; ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 10, 3)) +let b12: B1 & B2; +>b12 : Symbol(b12, Decl(objectSpreadIntersection.ts, 12, 3)) +>B1 : Symbol(B1, Decl(objectSpreadIntersection.ts, 8, 26)) +>B2 : Symbol(B2, Decl(objectSpreadIntersection.ts, 9, 26)) + +let result = { ...a12, ...b12 }; +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 13, 3)) let sn: number & string = result.a; ->sn : Symbol(sn, Decl(objectSpreadIntersection.ts, 11, 3)) +>sn : Symbol(sn, Decl(objectSpreadIntersection.ts, 14, 3)) >result.a : Symbol(a, Decl(objectSpreadIntersection.ts, 7, 14), Decl(objectSpreadIntersection.ts, 8, 14)) ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 10, 3)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 13, 3)) >a : Symbol(a, Decl(objectSpreadIntersection.ts, 7, 14), Decl(objectSpreadIntersection.ts, 8, 14)) -let assignable: { ...(A1 & A2) } = result; ->assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 12, 3)) +sn = result.b; +>sn : Symbol(sn, Decl(objectSpreadIntersection.ts, 14, 3)) +>result.b : Symbol(b, Decl(objectSpreadIntersection.ts, 9, 14), Decl(objectSpreadIntersection.ts, 10, 14)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 13, 3)) +>b : Symbol(b, Decl(objectSpreadIntersection.ts, 9, 14), Decl(objectSpreadIntersection.ts, 10, 14)) + +let assignable: { ...(A1 & A2), ...(B1 & B2) } = result; +>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 16, 3)) >A1 : Symbol(A1, Decl(objectSpreadIntersection.ts, 5, 1)) >A2 : Symbol(A2, Decl(objectSpreadIntersection.ts, 7, 26)) ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 10, 3)) +>B1 : Symbol(B1, Decl(objectSpreadIntersection.ts, 8, 26)) +>B2 : Symbol(B2, Decl(objectSpreadIntersection.ts, 9, 26)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 13, 3)) function tripleIntersection(t: T, u: U, v: V): void { ->tripleIntersection : Symbol(tripleIntersection, Decl(objectSpreadIntersection.ts, 12, 42)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 14, 28)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 14, 30)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 14, 33)) ->t : Symbol(t, Decl(objectSpreadIntersection.ts, 14, 37)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 14, 28)) ->u : Symbol(u, Decl(objectSpreadIntersection.ts, 14, 42)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 14, 30)) ->v : Symbol(v, Decl(objectSpreadIntersection.ts, 14, 48)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 14, 33)) +>tripleIntersection : Symbol(tripleIntersection, Decl(objectSpreadIntersection.ts, 16, 56)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 18, 28)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 18, 30)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 18, 33)) +>t : Symbol(t, Decl(objectSpreadIntersection.ts, 18, 37)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 18, 28)) +>u : Symbol(u, Decl(objectSpreadIntersection.ts, 18, 42)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 18, 30)) +>v : Symbol(v, Decl(objectSpreadIntersection.ts, 18, 48)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 18, 33)) let tuv: T & U & V; ->tuv : Symbol(tuv, Decl(objectSpreadIntersection.ts, 15, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 14, 28)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 14, 30)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 14, 33)) +>tuv : Symbol(tuv, Decl(objectSpreadIntersection.ts, 19, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 18, 28)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 18, 30)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 18, 33)) let result = { ...tuv, id: 'bar' }; ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 16, 7)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 16, 26)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 20, 7)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 20, 26)) let assignable: { ...(T & U & V), id: string } = result; ->assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 17, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 14, 28)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 14, 30)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 14, 33)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 17, 37)) ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 16, 7)) +>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 21, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 18, 28)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 18, 30)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 18, 33)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 21, 37)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 20, 7)) } function iteratedDoubleIntersection(t: T, u: U, v: V): void { ->iteratedDoubleIntersection : Symbol(iteratedDoubleIntersection, Decl(objectSpreadIntersection.ts, 18, 1)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 19, 36)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 19, 41)) ->t : Symbol(t, Decl(objectSpreadIntersection.ts, 19, 45)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 19, 36)) ->u : Symbol(u, Decl(objectSpreadIntersection.ts, 19, 50)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) ->v : Symbol(v, Decl(objectSpreadIntersection.ts, 19, 56)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 19, 41)) +>iteratedDoubleIntersection : Symbol(iteratedDoubleIntersection, Decl(objectSpreadIntersection.ts, 22, 1)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 23, 36)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 23, 41)) +>t : Symbol(t, Decl(objectSpreadIntersection.ts, 23, 45)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 23, 36)) +>u : Symbol(u, Decl(objectSpreadIntersection.ts, 23, 50)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) +>v : Symbol(v, Decl(objectSpreadIntersection.ts, 23, 56)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 23, 41)) let tu: T & U; ->tu : Symbol(tu, Decl(objectSpreadIntersection.ts, 20, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 19, 36)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) +>tu : Symbol(tu, Decl(objectSpreadIntersection.ts, 24, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 23, 36)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) let uv: U & V; ->uv : Symbol(uv, Decl(objectSpreadIntersection.ts, 21, 7)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 19, 41)) +>uv : Symbol(uv, Decl(objectSpreadIntersection.ts, 25, 7)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 23, 41)) let result = { ...tu, ...uv, id: 'baz' }; ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 22, 7)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 22, 32)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 26, 7)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 26, 32)) let assignable: { ...(T & U), ...(U & V), id: string } = result; ->assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 23, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 19, 36)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 19, 38)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 19, 41)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 23, 45)) ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 22, 7)) +>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 27, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 23, 36)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 23, 38)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 23, 41)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 27, 45)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 26, 7)) } function iteratedIntersectionUnion(t: T, u: U, v: V): void { ->iteratedIntersectionUnion : Symbol(iteratedIntersectionUnion, Decl(objectSpreadIntersection.ts, 24, 1)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 25, 35)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 25, 40)) ->t : Symbol(t, Decl(objectSpreadIntersection.ts, 25, 44)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 25, 35)) ->u : Symbol(u, Decl(objectSpreadIntersection.ts, 25, 49)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) ->v : Symbol(v, Decl(objectSpreadIntersection.ts, 25, 55)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 25, 40)) +>iteratedIntersectionUnion : Symbol(iteratedIntersectionUnion, Decl(objectSpreadIntersection.ts, 28, 1)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 29, 35)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 29, 40)) +>t : Symbol(t, Decl(objectSpreadIntersection.ts, 29, 44)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 29, 35)) +>u : Symbol(u, Decl(objectSpreadIntersection.ts, 29, 49)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) +>v : Symbol(v, Decl(objectSpreadIntersection.ts, 29, 55)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 29, 40)) let tu: T & U; ->tu : Symbol(tu, Decl(objectSpreadIntersection.ts, 26, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 25, 35)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) +>tu : Symbol(tu, Decl(objectSpreadIntersection.ts, 30, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 29, 35)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) let uv: U | V; ->uv : Symbol(uv, Decl(objectSpreadIntersection.ts, 27, 7)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 25, 40)) +>uv : Symbol(uv, Decl(objectSpreadIntersection.ts, 31, 7)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 29, 40)) let result = { ...tu, ...uv, id: 'qux' }; ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 28, 7)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 28, 32)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 32, 7)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 32)) let assignable: { ...(T & U), ...(U | V), id: string } = result; ->assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 29, 7)) ->T : Symbol(T, Decl(objectSpreadIntersection.ts, 25, 35)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) ->U : Symbol(U, Decl(objectSpreadIntersection.ts, 25, 37)) ->V : Symbol(V, Decl(objectSpreadIntersection.ts, 25, 40)) ->id : Symbol(id, Decl(objectSpreadIntersection.ts, 29, 45)) ->result : Symbol(result, Decl(objectSpreadIntersection.ts, 28, 7)) +>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 33, 7)) +>T : Symbol(T, Decl(objectSpreadIntersection.ts, 29, 35)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) +>U : Symbol(U, Decl(objectSpreadIntersection.ts, 29, 37)) +>V : Symbol(V, Decl(objectSpreadIntersection.ts, 29, 40)) +>id : Symbol(id, Decl(objectSpreadIntersection.ts, 33, 45)) +>result : Symbol(result, Decl(objectSpreadIntersection.ts, 32, 7)) } diff --git a/tests/baselines/reference/objectSpreadIntersection.types b/tests/baselines/reference/objectSpreadIntersection.types index 0e21f42a76b..13c1384698f 100644 --- a/tests/baselines/reference/objectSpreadIntersection.types +++ b/tests/baselines/reference/objectSpreadIntersection.types @@ -47,27 +47,50 @@ interface A2 { a: string } >A2 : A2 >a : string +interface B1 { b: number } +>B1 : B1 +>b : number + +interface B2 { b: string } +>B2 : B2 +>b : string + let a12: A1 & A2; >a12 : A1 & A2 >A1 : A1 >A2 : A2 -let result = { ...a12 }; ->result : { ...A1 & A2 } ->{ ...a12 } : { ...A1 & A2 } +let b12: B1 & B2; +>b12 : B1 & B2 +>B1 : B1 +>B2 : B2 + +let result = { ...a12, ...b12 }; +>result : { b: number & string; a: number & string; } +>{ ...a12, ...b12 } : { b: number & string; a: number & string; } >a12 : any +>b12 : any let sn: number & string = result.a; >sn : number & string >result.a : number & string ->result : { ...A1 & A2 } +>result : { b: number & string; a: number & string; } >a : number & string -let assignable: { ...(A1 & A2) } = result; ->assignable : { ...A1 & A2 } +sn = result.b; +>sn = result.b : number & string +>sn : number & string +>result.b : number & string +>result : { b: number & string; a: number & string; } +>b : number & string + +let assignable: { ...(A1 & A2), ...(B1 & B2) } = result; +>assignable : { b: number & string; a: number & string; } >A1 : A1 >A2 : A2 ->result : { ...A1 & A2 } +>B1 : B1 +>B2 : B2 +>result : { b: number & string; a: number & string; } function tripleIntersection(t: T, u: U, v: V): void { >tripleIntersection : (t: T, u: U, v: V) => void diff --git a/tests/cases/conformance/types/spread/objectSpreadIntersection.ts b/tests/cases/conformance/types/spread/objectSpreadIntersection.ts index 636283dd715..3bedacca89f 100644 --- a/tests/cases/conformance/types/spread/objectSpreadIntersection.ts +++ b/tests/cases/conformance/types/spread/objectSpreadIntersection.ts @@ -7,10 +7,14 @@ function iteratedUnionIntersection(t: T, u: U, v: V): void { // concrete types work interface A1 { a: number } interface A2 { a: string } +interface B1 { b: number } +interface B2 { b: string } let a12: A1 & A2; -let result = { ...a12 }; +let b12: B1 & B2; +let result = { ...a12, ...b12 }; let sn: number & string = result.a; -let assignable: { ...(A1 & A2) } = result; +sn = result.b; +let assignable: { ...(A1 & A2), ...(B1 & B2) } = result; function tripleIntersection(t: T, u: U, v: V): void { let tuv: T & U & V;