mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Update tests w/spread assignability+apparent type
This commit is contained in:
parent
a90905358d
commit
ad10ec56c1
@ -83,8 +83,8 @@ let a = 12;
|
||||
let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U): { id: string, ...T, ...U } {
|
||||
return { id: 'id', ...t, ...u };
|
||||
function f<T, U>(t: T, u: U): { ...T, ...U, id: string } {
|
||||
return { ...t, ...u, id: 'id' };
|
||||
}
|
||||
let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
f({ a: 1, b: 'yes' }, { c: 'no', d: false })
|
||||
@ -92,7 +92,7 @@ let overlap: { id: string, a: number, b: string } =
|
||||
f({ a: 1 }, { a: 2, b: 'extra' })
|
||||
let overlapConflict: { id:string, a: string } =
|
||||
f({ a: 1 }, { a: 'mismatch' })
|
||||
let overwriteId: { id: boolean, a: number, c: number, d: string } =
|
||||
let overwriteId: { id: string, a: number, c: number, d: string } =
|
||||
f({ a: 1, id: true }, { c: 1, d: 'no' })
|
||||
|
||||
class D { m() { }; q = 2; }
|
||||
@ -172,7 +172,7 @@ var a = 12;
|
||||
var shortCutted = __assign({}, o, { a: a });
|
||||
// generics
|
||||
function f(t, u) {
|
||||
return __assign({ id: 'id' }, t, u);
|
||||
return __assign({}, t, u, { id: 'id' });
|
||||
}
|
||||
var exclusive = f({ a: 1, b: 'yes' }, { c: 'no', d: false });
|
||||
var overlap = f({ a: 1 }, { a: 2, b: 'extra' });
|
||||
|
||||
@ -290,7 +290,7 @@ let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 81, 51))
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U): { id: string, ...T, ...U } {
|
||||
function f<T, U>(t: T, u: U): { ...T, ...U, id: string } {
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 84, 11))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 84, 13))
|
||||
@ -298,12 +298,12 @@ function f<T, U>(t: T, u: U): { id: string, ...T, ...U } {
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 84, 11))
|
||||
>u : Symbol(u, Decl(objectSpread.ts, 84, 22))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 84, 13))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 84, 31))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 84, 11))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 84, 13))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 84, 43))
|
||||
|
||||
return { id: 'id', ...t, ...u };
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 85, 12))
|
||||
return { ...t, ...u, id: 'id' };
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 85, 24))
|
||||
}
|
||||
let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
>exclusive : Symbol(exclusive, Decl(objectSpread.ts, 87, 3))
|
||||
@ -342,12 +342,12 @@ let overlapConflict: { id:string, a: string } =
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 92, 7))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 92, 17))
|
||||
|
||||
let overwriteId: { id: boolean, a: number, c: number, d: string } =
|
||||
let overwriteId: { id: string, a: number, c: number, d: string } =
|
||||
>overwriteId : Symbol(overwriteId, Decl(objectSpread.ts, 93, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 93, 18))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 93, 31))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 93, 42))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 93, 53))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 93, 30))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 93, 41))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 93, 52))
|
||||
|
||||
f({ a: 1, id: true }, { c: 1, d: 'no' })
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
|
||||
@ -423,24 +423,24 @@ let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
>a : number
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U): { id: string, ...T, ...U } {
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
function f<T, U>(t: T, u: U): { ...T, ...U, id: string } {
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>t : T
|
||||
>T : T
|
||||
>u : U
|
||||
>U : U
|
||||
>id : string
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
return { id: 'id', ...t, ...u };
|
||||
>{ id: 'id', ...t, ...u } : { id: string; ...T; ...U }
|
||||
>id : string
|
||||
>'id' : "id"
|
||||
|
||||
return { ...t, ...u, id: 'id' };
|
||||
>{ ...t, ...u, id: 'id' } : { ...T; ...U; id: string; }
|
||||
>t : any
|
||||
>u : any
|
||||
>id : string
|
||||
>'id' : "id"
|
||||
}
|
||||
let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
>exclusive : { id: string; a: number; b: string; c: string; d: boolean; }
|
||||
@ -451,8 +451,8 @@ let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
>d : boolean
|
||||
|
||||
f({ a: 1, b: 'yes' }, { c: 'no', d: false })
|
||||
>f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { c: string; d: boolean; a: number; b: string; id: string; }
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
>f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { id: string; c: string; d: boolean; a: number; b: string; }
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>{ a: 1, b: 'yes' } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
@ -471,8 +471,8 @@ let overlap: { id: string, a: number, b: string } =
|
||||
>b : string
|
||||
|
||||
f({ a: 1 }, { a: 2, b: 'extra' })
|
||||
>f({ a: 1 }, { a: 2, b: 'extra' }) : { a: number; b: string; id: string; }
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
>f({ a: 1 }, { a: 2, b: 'extra' }) : { id: string; a: number; b: string; }
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
@ -488,8 +488,8 @@ let overlapConflict: { id:string, a: string } =
|
||||
>a : string
|
||||
|
||||
f({ a: 1 }, { a: 'mismatch' })
|
||||
>f({ a: 1 }, { a: 'mismatch' }) : { a: string; id: string; }
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
>f({ a: 1 }, { a: 'mismatch' }) : { id: string; a: string; }
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
@ -497,16 +497,16 @@ let overlapConflict: { id:string, a: string } =
|
||||
>a : string
|
||||
>'mismatch' : "mismatch"
|
||||
|
||||
let overwriteId: { id: boolean, a: number, c: number, d: string } =
|
||||
>overwriteId : { id: boolean; a: number; c: number; d: string; }
|
||||
>id : boolean
|
||||
let overwriteId: { id: string, a: number, c: number, d: string } =
|
||||
>overwriteId : { id: string; a: number; c: number; d: string; }
|
||||
>id : string
|
||||
>a : number
|
||||
>c : number
|
||||
>d : string
|
||||
|
||||
f({ a: 1, id: true }, { c: 1, d: 'no' })
|
||||
>f({ a: 1, id: true }, { c: 1, d: 'no' }) : { c: number; d: string; a: number; id: boolean; }
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
>f({ a: 1, id: true }, { c: 1, d: 'no' }) : { id: string; c: number; d: string; a: number; }
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>{ a: 1, id: true } : { a: number; id: true; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
@ -531,8 +531,8 @@ let classesAreWrong: { id: string, ...C, ...D } =
|
||||
>D : D
|
||||
|
||||
f(new C(), new D())
|
||||
>f(new C(), new D()) : { q: number; p: number; id: string; }
|
||||
>f : <T, U>(t: T, u: U) => { id: string; ...T; ...U }
|
||||
>f(new C(), new D()) : { id: string; q: number; p: number; }
|
||||
>f : <T, U>(t: T, u: U) => { ...T; ...U; id: string; }
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
>new D() : D
|
||||
|
||||
@ -4,17 +4,19 @@ tests/cases/conformance/types/spread/objectSpreadGeneric.ts(11,11): error TS2322
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(12,11): error TS2322: Type '{ ...T; ...U; ...V }' is not assignable to type '{ ...U; ...V }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(13,11): error TS2322: Type '{ ...T; ...U; ...V }' is not assignable to type '{ ...T; ...V }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(14,11): error TS2322: Type '{ ...T; ...U; ...V }' is not assignable to type '{ ...T; ...U }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(16,11): error TS2322: Type '{ first: string; ...T; ...U }' is not assignable to type '{ first: string; ...T; ...U }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(19,11): error TS2322: Type '{}' is not assignable to type '{ ...T; ...U }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(32,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; second: string; ...T; third: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(40,11): error TS2322: Type '{ firrrrrrst: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
Property 'first' is missing in type '{ third: string; second: string; firrrrrrst: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(42,11): error TS2322: Type '{ first: string; ...T; ssssssssecond: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
Property 'second' is missing in type '{ third: string; ssssssssecond: string; first: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(44,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; thirrrrrrrd: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
Property 'third' is missing in type '{ thirrrrrrrd: string; second: string; first: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(26,11): error TS2322: Type '{ sn?: boolean; ...T; sn?: string | number; }' is not assignable to type '{ ...T; sn?: string | number | boolean; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(32,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(34,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; second: string; ...T; third: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(36,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(38,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }' is not assignable to type '{ first: string; second: string; secondsecond: string; third: string; ...T; ...U }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(42,11): error TS2322: Type '{ firrrrrrst: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(44,11): error TS2322: Type '{ first: string; ...T; ssssssssecond: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadGeneric.ts(46,11): error TS2322: Type '{ first: string; ...T; second: string; ...U; thirrrrrrrd: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/objectSpreadGeneric.ts (11 errors) ====
|
||||
==== tests/cases/conformance/types/spread/objectSpreadGeneric.ts (16 errors) ====
|
||||
function f<T, U, V>(t: T, u: U, v: V): void {
|
||||
let o: { ...T, ...U, ...V };
|
||||
let uus: { ...U, ...U};
|
||||
@ -42,48 +44,57 @@ tests/cases/conformance/types/spread/objectSpreadGeneric.ts(44,11): error TS2322
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ ...T; ...U; ...V }' is not assignable to type '{ ...T; ...U }'.
|
||||
const atEnd: { ...T, ...U, second: string } = { ...t, ...u, second: 'foo' }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // error, not assignable
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; ...U }' is not assignable to type '{ first: string; ...T; ...U }'.
|
||||
|
||||
const emptyTarget: { } = { ...t, ...u } // ok
|
||||
const emptySource: { ...T, ...U } = { }; // error, {} is not assignable to U (or T)
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type '{ ...T; ...U }'.
|
||||
|
||||
// error, { sn?: boolean } ...T ... { sn?: number | string } is not assignable to
|
||||
// T ... { sn?: number | string | boolean }
|
||||
let optionalNumber: { sn?: number };
|
||||
let optionalString: { sn?: string };
|
||||
let optionalBoolean: { sn?: boolean };
|
||||
const unionCutoff: { ...T, sn?: number | string | boolean } =
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber } // ok
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ sn?: boolean; ...T; sn?: string | number; }' is not assignable to type '{ ...T; sn?: string | number | boolean; }'.
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber }
|
||||
unionCutoff.sn; // ok
|
||||
const optionalCutoff = { ...t, ...optionalNumber }; // ok
|
||||
optionalCutoff.sn; // ok
|
||||
|
||||
const interspersed: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // ok
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const interspersedMissingU: { first: string, second: string, ...T, third: string } =
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; second: string; ...T; third: string; }'.
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, 'U' is missing
|
||||
const interspersedOrder1: { first: string, ...T, second: string, ...U, third: string, secondsecond: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }'.
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
const interspersedOrder2: { first: string, second: string, secondsecond: string, third: string, ...T, ...U } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; second: string; ...U; third: string; secondsecond: string; }' is not assignable to type '{ first: string; second: string; secondsecond: string; third: string; ...T; ...U }'.
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
|
||||
|
||||
const mismatchFirst: { first: string, ...T, second: string, ...U, third: string } =
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ firrrrrrst: string; ...T; second: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
!!! error TS2322: Property 'first' is missing in type '{ third: string; second: string; firrrrrrst: string; }'.
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, 'first' not found
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchSecond: { first: string, ...T, second: string, ...U, third: string } =
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; ssssssssecond: string; ...U; third: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
!!! error TS2322: Property 'second' is missing in type '{ third: string; ssssssssecond: string; first: string; }'.
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, 'second' not found
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchLast: { first: string, ...T, second: string, ...U, third: string } =
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ first: string; ...T; second: string; ...U; thirrrrrrrd: string; }' is not assignable to type '{ first: string; ...T; second: string; ...U; third: string; }'.
|
||||
!!! error TS2322: Property 'third' is missing in type '{ thirrrrrrrd: string; second: string; first: string; }'.
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, 'third' not found
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, not assignable
|
||||
}
|
||||
|
||||
@ -14,36 +14,38 @@ function f<T, U, V>(t: T, u: U, v: V): void {
|
||||
const missingU: { ...T, ...V } = o; // error, missing U
|
||||
const missingV: { ...T, ...U } = o; // error, missing V
|
||||
const atEnd: { ...T, ...U, second: string } = { ...t, ...u, second: 'foo' }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // error, not assignable
|
||||
|
||||
const emptyTarget: { } = { ...t, ...u } // ok
|
||||
const emptySource: { ...T, ...U } = { }; // error, {} is not assignable to U (or T)
|
||||
|
||||
// error, { sn?: boolean } ...T ... { sn?: number | string } is not assignable to
|
||||
// T ... { sn?: number | string | boolean }
|
||||
let optionalNumber: { sn?: number };
|
||||
let optionalString: { sn?: string };
|
||||
let optionalBoolean: { sn?: boolean };
|
||||
const unionCutoff: { ...T, sn?: number | string | boolean } =
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber } // ok
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber }
|
||||
unionCutoff.sn; // ok
|
||||
const optionalCutoff = { ...t, ...optionalNumber }; // ok
|
||||
optionalCutoff.sn; // ok
|
||||
|
||||
const interspersed: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const interspersedMissingU: { first: string, second: string, ...T, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, 'U' is missing
|
||||
const interspersedOrder1: { first: string, ...T, second: string, ...U, third: string, secondsecond: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
const interspersedOrder2: { first: string, second: string, secondsecond: string, third: string, ...T, ...U } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
|
||||
|
||||
const mismatchFirst: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, 'first' not found
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchSecond: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, 'second' not found
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchLast: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, 'third' not found
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, not assignable
|
||||
}
|
||||
|
||||
|
||||
@ -71,21 +73,23 @@ function f(t, u, v) {
|
||||
var missingU = o; // error, missing U
|
||||
var missingV = o; // error, missing V
|
||||
var atEnd = __assign({}, t, u, { second: 'foo' }); // ok
|
||||
var atBeginning = __assign({ first: 'foo' }, t, u); // ok
|
||||
var atBeginning = __assign({ first: 'foo' }, t, u); // error, not assignable
|
||||
var emptyTarget = __assign({}, t, u); // ok
|
||||
var emptySource = {}; // error, {} is not assignable to U (or T)
|
||||
// error, { sn?: boolean } ...T ... { sn?: number | string } is not assignable to
|
||||
// T ... { sn?: number | string | boolean }
|
||||
var optionalNumber;
|
||||
var optionalString;
|
||||
var optionalBoolean;
|
||||
var unionCutoff = __assign({}, optionalBoolean, t, optionalString, optionalNumber); // ok
|
||||
var unionCutoff = __assign({}, optionalBoolean, t, optionalString, optionalNumber);
|
||||
unionCutoff.sn; // ok
|
||||
var optionalCutoff = __assign({}, t, optionalNumber); // ok
|
||||
optionalCutoff.sn; // ok
|
||||
var interspersed = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3' }); // ok
|
||||
var interspersed = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3' }); // error, not assignable
|
||||
var interspersedMissingU = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3' }); // error, 'U' is missing
|
||||
var interspersedOrder1 = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3', secondsecond: 'false' }); // ok
|
||||
var interspersedOrder2 = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3', secondsecond: 'false' }); // ok
|
||||
var mismatchFirst = __assign({ firrrrrrst: '1' }, t, { second: '2' }, u, { third: '3' }); // error, 'first' not found
|
||||
var mismatchSecond = __assign({ first: '1' }, t, { ssssssssecond: '2' }, u, { third: '3' }); // error, 'second' not found
|
||||
var mismatchLast = __assign({ first: '1' }, t, { second: '2' }, u, { thirrrrrrrd: '3' }); // error, 'third' not found
|
||||
var interspersedOrder1 = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3', secondsecond: 'false' }); // error, not assignable
|
||||
var interspersedOrder2 = __assign({ first: '1' }, t, { second: '2' }, u, { third: '3', secondsecond: 'false' }); // error, not assignable
|
||||
var mismatchFirst = __assign({ firrrrrrst: '1' }, t, { second: '2' }, u, { third: '3' }); // error, not assignable
|
||||
var mismatchSecond = __assign({ first: '1' }, t, { ssssssssecond: '2' }, u, { third: '3' }); // error, not assignable
|
||||
var mismatchLast = __assign({ first: '1' }, t, { second: '2' }, u, { thirrrrrrrd: '3' }); // error, not assignable
|
||||
}
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
function iteratedUnionIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T | U;
|
||||
let uv: U & V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...T, ...V }) | ({ id: string, ...U } & { id: string, ...U, ...V });
|
||||
let assignable: { id: string, ...(T | U), ...(U & V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'foo' };
|
||||
let expected: ({ ...T, ...U, id: string } & { ...T, ...V, id: string }) | ({ ...U, id: string } & { ...U, ...V, id: string });
|
||||
let assignable: { ...(T | U), ...(U & V), id: string } = result;
|
||||
}
|
||||
// concrete types work
|
||||
interface A1 { a: number }
|
||||
@ -16,23 +16,23 @@ let assignable: { ...(A1 & A2) } = result;
|
||||
|
||||
function tripleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tuv: T & U & V;
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let expected: { id: string, ...T } & { id: string, ...U } & { id: string, ...V } = result;
|
||||
let assignable: { id: string, ...(T & U & V) } = result;
|
||||
let result = { ...tuv, id: 'bar' };
|
||||
let expected: { ...T, id: string } & { ...U, id: string } & { ...V, id: string } = result;
|
||||
let assignable: { ...(T & U & V), id: string } = result;
|
||||
}
|
||||
function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T & U;
|
||||
let uv: U & V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: { id: string, ...T, ...U } & { id: string, ...T, ...V } & { id: string, ...U } & { id: string, ...U, ...V };
|
||||
let assignable: { id: string, ...(T & U), ...(U & V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'baz' };
|
||||
let expected: { ...T, ...U, id: string } & { ...T, ...V, id: string } & { ...U, id: string } & { ...U, ...V, id: string };
|
||||
let assignable: { ...(T & U), ...(U & V), id: string } = result;
|
||||
}
|
||||
function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T & U;
|
||||
let uv: U | V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...U }) | ({ id: string, ...T, ...V } & { id: string, ...U, ...V });
|
||||
let assignable: { id: string, ...(T & U), ...(U | V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'qux' };
|
||||
let expected: ({ ...T, ...U, id: string } & { ...U, id: string }) | ({ ...T, ...V, id: string } & { ...U, ...V, id: string });
|
||||
let assignable: { ...(T & U), ...(U | V), id: string } = result;
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
function iteratedUnionIntersection(t, u, v) {
|
||||
var tu;
|
||||
var uv;
|
||||
var result = __assign({ id: 'bar' }, tu, uv);
|
||||
var result = __assign({}, tu, uv, { id: 'foo' });
|
||||
var expected;
|
||||
var assignable = result;
|
||||
}
|
||||
@ -59,21 +59,21 @@ var sn = result.a;
|
||||
var assignable = result;
|
||||
function tripleIntersection(t, u, v) {
|
||||
var tuv;
|
||||
var result = __assign({ id: 'foo' }, tuv);
|
||||
var result = __assign({}, tuv, { id: 'bar' });
|
||||
var expected = result;
|
||||
var assignable = result;
|
||||
}
|
||||
function iteratedDoubleIntersection(t, u, v) {
|
||||
var tu;
|
||||
var uv;
|
||||
var result = __assign({ id: 'bar' }, tu, uv);
|
||||
var result = __assign({}, tu, uv, { id: 'baz' });
|
||||
var expected;
|
||||
var assignable = result;
|
||||
}
|
||||
function iteratedIntersectionUnion(t, u, v) {
|
||||
var tu;
|
||||
var uv;
|
||||
var result = __assign({ id: 'bar' }, tu, uv);
|
||||
var result = __assign({}, tu, uv, { id: 'qux' });
|
||||
var expected;
|
||||
var assignable = result;
|
||||
}
|
||||
|
||||
@ -21,31 +21,31 @@ function iteratedUnionIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 0, 40))
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let result = { ...tu, ...uv, id: 'foo' };
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 3, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 3, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 3, 32))
|
||||
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...T, ...V }) | ({ id: string, ...U } & { id: string, ...U, ...V });
|
||||
let expected: ({ ...T, ...U, id: string } & { ...T, ...V, id: string }) | ({ ...U, id: string } & { ...U, ...V, id: string });
|
||||
>expected : Symbol(expected, Decl(objectSpreadIntersection.ts, 4, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 20))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 0, 35))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 49))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 32))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 0, 35))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 0, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 80))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 61))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 103))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 86))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 0, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 4, 115))
|
||||
|
||||
let assignable: { id: string, ...(T | U), ...(U & V) } = result;
|
||||
let assignable: { ...(T | U), ...(U & V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 5, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 5, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 0, 35))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 0, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 0, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 5, 45))
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 3, 7))
|
||||
}
|
||||
// concrete types work
|
||||
@ -95,26 +95,26 @@ function tripleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 15, 30))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 15, 33))
|
||||
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let result = { ...tuv, id: 'bar' };
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 17, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 17, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 17, 26))
|
||||
|
||||
let expected: { id: string, ...T } & { id: string, ...U } & { id: string, ...V } = result;
|
||||
let expected: { ...T, id: string } & { ...U, id: string } & { ...V, id: string } = result;
|
||||
>expected : Symbol(expected, Decl(objectSpreadIntersection.ts, 18, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 19))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 15, 28))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 42))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 25))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 15, 30))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 65))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 48))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 15, 33))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 18, 71))
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 17, 7))
|
||||
|
||||
let assignable: { id: string, ...(T & U & V) } = result;
|
||||
let assignable: { ...(T & U & V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 19, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 19, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 15, 28))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 15, 30))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 15, 33))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 19, 37))
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 17, 7))
|
||||
}
|
||||
function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
@ -139,31 +139,31 @@ function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 21, 41))
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let result = { ...tu, ...uv, id: 'baz' };
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 24, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 24, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 24, 32))
|
||||
|
||||
let expected: { id: string, ...T, ...U } & { id: string, ...T, ...V } & { id: string, ...U } & { id: string, ...U, ...V };
|
||||
let expected: { ...T, ...U, id: string } & { ...T, ...V, id: string } & { ...U, id: string } & { ...U, ...V, id: string };
|
||||
>expected : Symbol(expected, Decl(objectSpreadIntersection.ts, 25, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 19))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 21, 36))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 48))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 31))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 21, 36))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 21, 41))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 77))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 60))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 100))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 83))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 21, 41))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 25, 112))
|
||||
|
||||
let assignable: { id: string, ...(T & U), ...(U & V) } = result;
|
||||
let assignable: { ...(T & U), ...(U & V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 26, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 26, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 21, 36))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 21, 38))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 21, 41))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 26, 45))
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 24, 7))
|
||||
}
|
||||
function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
@ -188,31 +188,31 @@ function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 28, 40))
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let result = { ...tu, ...uv, id: 'qux' };
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 31, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 31, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 31, 32))
|
||||
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...U }) | ({ id: string, ...T, ...V } & { id: string, ...U, ...V });
|
||||
let expected: ({ ...T, ...U, id: string } & { ...U, id: string }) | ({ ...T, ...V, id: string } & { ...U, ...V, id: string });
|
||||
>expected : Symbol(expected, Decl(objectSpreadIntersection.ts, 32, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 20))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 28, 35))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 49))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 32))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 74))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 55))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 28, 35))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 28, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 103))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 86))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 28, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 32, 115))
|
||||
|
||||
let assignable: { id: string, ...(T & U), ...(U | V) } = result;
|
||||
let assignable: { ...(T & U), ...(U | V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadIntersection.ts, 33, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 33, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadIntersection.ts, 28, 35))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>U : Symbol(U, Decl(objectSpreadIntersection.ts, 28, 37))
|
||||
>V : Symbol(V, Decl(objectSpreadIntersection.ts, 28, 40))
|
||||
>id : Symbol(id, Decl(objectSpreadIntersection.ts, 33, 45))
|
||||
>result : Symbol(result, Decl(objectSpreadIntersection.ts, 31, 7))
|
||||
}
|
||||
|
||||
|
||||
@ -21,17 +21,16 @@ function iteratedUnionIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
>result : ({ id: string; ...T; ...U } | { id: string; ...U }) & ({ id: string; ...T; ...V } | { id: string; ...U; ...V })
|
||||
>{ id: 'bar', ...tu, ...uv } : ({ id: string; ...T; ...U } | { id: string; ...U }) & ({ id: string; ...T; ...V } | { id: string; ...U; ...V })
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
let result = { ...tu, ...uv, id: 'foo' };
|
||||
>result : ({ ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...U; ...T; ...U; id: string; }) & ({ ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; } | { ...T; ...U; ...T; ...V; id: string; } | { ...U; ...T; ...U; ...V; id: string; })
|
||||
>{ ...tu, ...uv, id: 'foo' } : ({ ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...U; ...T; ...U; id: string; }) & ({ ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; } | { ...T; ...U; ...T; ...V; id: string; } | { ...U; ...T; ...U; ...V; id: string; })
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
>'foo' : "foo"
|
||||
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...T, ...V }) | ({ id: string, ...U } & { id: string, ...U, ...V });
|
||||
>expected : ({ id: string; ...T; ...U } & { id: string; ...T; ...V }) | ({ id: string; ...U } & { id: string; ...U; ...V })
|
||||
>id : string
|
||||
let expected: ({ ...T, ...U, id: string } & { ...T, ...V, id: string }) | ({ ...U, id: string } & { ...U, ...V, id: string });
|
||||
>expected : ({ ...T; ...U; id: string; } & { ...T; ...V; id: string; }) | ({ ...U; id: string; } & { ...U; ...V; id: string; })
|
||||
>T : T
|
||||
>U : U
|
||||
>id : string
|
||||
@ -42,15 +41,16 @@ function iteratedUnionIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>id : string
|
||||
>U : U
|
||||
>V : V
|
||||
>id : string
|
||||
|
||||
let assignable: { id: string, ...(T | U), ...(U & V) } = result;
|
||||
>assignable : ({ id: string; ...T; ...U } | { id: string; ...U }) & ({ id: string; ...T; ...V } | { id: string; ...U; ...V })
|
||||
>id : string
|
||||
let assignable: { ...(T | U), ...(U & V), id: string } = result;
|
||||
>assignable : ({ ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...U; ...T; ...U; id: string; }) & ({ ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; } | { ...T; ...U; ...T; ...V; id: string; } | { ...U; ...T; ...U; ...V; id: string; })
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : V
|
||||
>result : ({ id: string; ...T; ...U } | { id: string; ...U }) & ({ id: string; ...T; ...V } | { id: string; ...U; ...V })
|
||||
>id : string
|
||||
>result : ({ ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...U; ...T; ...U; id: string; }) & ({ ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; } | { ...T; ...U; ...T; ...V; id: string; } | { ...U; ...T; ...U; ...V; id: string; })
|
||||
}
|
||||
// concrete types work
|
||||
interface A1 { a: number }
|
||||
@ -101,30 +101,30 @@ function tripleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'foo', ...tuv };
|
||||
>result : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
>{ id: 'foo', ...tuv } : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
>id : string
|
||||
>'foo' : "foo"
|
||||
let result = { ...tuv, id: 'bar' };
|
||||
>result : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
>{ ...tuv, id: 'bar' } : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
>tuv : any
|
||||
|
||||
let expected: { id: string, ...T } & { id: string, ...U } & { id: string, ...V } = result;
|
||||
>expected : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
|
||||
let expected: { ...T, id: string } & { ...U, id: string } & { ...V, id: string } = result;
|
||||
>expected : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
>T : T
|
||||
>id : string
|
||||
>U : U
|
||||
>id : string
|
||||
>V : V
|
||||
>result : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
|
||||
let assignable: { id: string, ...(T & U & V) } = result;
|
||||
>assignable : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
>id : string
|
||||
>result : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
|
||||
let assignable: { ...(T & U & V), id: string } = result;
|
||||
>assignable : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>V : V
|
||||
>result : { id: string; ...T } & { id: string; ...U } & { id: string; ...V }
|
||||
>id : string
|
||||
>result : { ...T; id: string; } & { ...U; id: string; } & { ...V; id: string; }
|
||||
}
|
||||
function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>iteratedDoubleIntersection : <T, U, V>(t: T, u: U, v: V) => void
|
||||
@ -148,17 +148,16 @@ function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
>result : { id: string; ...T; ...U } & { id: string; ...U } & { id: string; ...T; ...V } & { id: string; ...U; ...V }
|
||||
>{ id: 'bar', ...tu, ...uv } : { id: string; ...T; ...U } & { id: string; ...U } & { id: string; ...T; ...V } & { id: string; ...U; ...V }
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
let result = { ...tu, ...uv, id: 'baz' };
|
||||
>result : { ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...U; id: string; } & { ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; }
|
||||
>{ ...tu, ...uv, id: 'baz' } : { ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...U; id: string; } & { ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; }
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
>'baz' : "baz"
|
||||
|
||||
let expected: { id: string, ...T, ...U } & { id: string, ...T, ...V } & { id: string, ...U } & { id: string, ...U, ...V };
|
||||
>expected : { id: string; ...T; ...U } & { id: string; ...T; ...V } & { id: string; ...U } & { id: string; ...U; ...V }
|
||||
>id : string
|
||||
let expected: { ...T, ...U, id: string } & { ...T, ...V, id: string } & { ...U, id: string } & { ...U, ...V, id: string };
|
||||
>expected : { ...T; ...U; id: string; } & { ...T; ...V; id: string; } & { ...U; id: string; } & { ...U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>id : string
|
||||
@ -169,15 +168,16 @@ function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
>id : string
|
||||
>U : U
|
||||
>V : V
|
||||
>id : string
|
||||
|
||||
let assignable: { id: string, ...(T & U), ...(U & V) } = result;
|
||||
>assignable : { id: string; ...T; ...U } & { id: string; ...U } & { id: string; ...T; ...V } & { id: string; ...U; ...V }
|
||||
>id : string
|
||||
let assignable: { ...(T & U), ...(U & V), id: string } = result;
|
||||
>assignable : { ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...U; id: string; } & { ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : V
|
||||
>result : { id: string; ...T; ...U } & { id: string; ...U } & { id: string; ...T; ...V } & { id: string; ...U; ...V }
|
||||
>id : string
|
||||
>result : { ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...U; id: string; } & { ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; }
|
||||
}
|
||||
function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>iteratedIntersectionUnion : <T, U, V>(t: T, u: U, v: V) => void
|
||||
@ -201,17 +201,16 @@ function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
>result : ({ id: string; ...T; ...U } & { id: string; ...U }) | ({ id: string; ...T; ...V } & { id: string; ...U; ...V })
|
||||
>{ id: 'bar', ...tu, ...uv } : ({ id: string; ...T; ...U } & { id: string; ...U }) | ({ id: string; ...T; ...V } & { id: string; ...U; ...V })
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
let result = { ...tu, ...uv, id: 'qux' };
|
||||
>result : ({ ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...T; ...U; ...T; ...U; id: string; } & { ...U; id: string; }) | ({ ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; })
|
||||
>{ ...tu, ...uv, id: 'qux' } : ({ ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...T; ...U; ...T; ...U; id: string; } & { ...U; id: string; }) | ({ ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; })
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
>'qux' : "qux"
|
||||
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...U }) | ({ id: string, ...T, ...V } & { id: string, ...U, ...V });
|
||||
>expected : ({ id: string; ...T; ...U } & { id: string; ...U }) | ({ id: string; ...T; ...V } & { id: string; ...U; ...V })
|
||||
>id : string
|
||||
let expected: ({ ...T, ...U, id: string } & { ...U, id: string }) | ({ ...T, ...V, id: string } & { ...U, ...V, id: string });
|
||||
>expected : ({ ...T; ...U; id: string; } & { ...U; id: string; }) | ({ ...T; ...V; id: string; } & { ...U; ...V; id: string; })
|
||||
>T : T
|
||||
>U : U
|
||||
>id : string
|
||||
@ -222,15 +221,16 @@ function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>id : string
|
||||
>U : U
|
||||
>V : V
|
||||
>id : string
|
||||
|
||||
let assignable: { id: string, ...(T & U), ...(U | V) } = result;
|
||||
>assignable : ({ id: string; ...T; ...U } & { id: string; ...U }) | ({ id: string; ...T; ...V } & { id: string; ...U; ...V })
|
||||
>id : string
|
||||
let assignable: { ...(T & U), ...(U | V), id: string } = result;
|
||||
>assignable : ({ ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...T; ...U; ...T; ...U; id: string; } & { ...U; id: string; }) | ({ ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; })
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : V
|
||||
>result : ({ id: string; ...T; ...U } & { id: string; ...U }) | ({ id: string; ...T; ...V } & { id: string; ...U; ...V })
|
||||
>id : string
|
||||
>result : ({ ...T; ...U; id: string; } & { ...U; ...T; ...U; id: string; } & { ...T; ...U; ...T; ...U; id: string; } & { ...U; id: string; }) | ({ ...T; ...V; id: string; } & { ...U; ...T; ...V; id: string; } & { ...T; ...U; ...T; ...V; id: string; } & { ...T; ...U; ...V; id: string; } & { ...U; ...T; ...U; ...V; id: string; } & { ...U; ...V; id: string; })
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -9,16 +9,16 @@ let assignable: { ...(A1 | A2) } = result;
|
||||
|
||||
function tripleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tuv: T | U | V;
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let expected: { id: string, ...T } | { id: string, ...U } | { id: string, ...V } = result;
|
||||
let assignable: { id: string, ...(T | U | V) } = result;
|
||||
let result = { ...tuv, id: 'foo' };
|
||||
let expected: { ...T, id: string } | { ...U, id: string } | { ...V, id: string } = result;
|
||||
let assignable: { ...(T | U | V), id: string } = result;
|
||||
}
|
||||
function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T | U;
|
||||
let uv: U | V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: { id: string, ...T, ...U } | { id: string, ...T, ...V } | { id: string, ...U } | { id: string, ...U, ...V };
|
||||
let assignable: { id: string, ...(T | U), ...(U | V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'bar' };
|
||||
let expected: { ...T, ...U, id: string } | { ...T, ...V, id: string } | { ...U, id: string } | { ...U, ...V, id: string };
|
||||
let assignable: { ...(T | U), ...(U | V), id: string } = result;
|
||||
}
|
||||
|
||||
|
||||
@ -39,14 +39,14 @@ var sn = result.a;
|
||||
var assignable = result;
|
||||
function tripleUnion(t, u, v) {
|
||||
var tuv;
|
||||
var result = __assign({ id: 'foo' }, tuv);
|
||||
var result = __assign({}, tuv, { id: 'foo' });
|
||||
var expected = result;
|
||||
var assignable = result;
|
||||
}
|
||||
function iteratedDoubleUnion(t, u, v) {
|
||||
var tu;
|
||||
var uv;
|
||||
var result = __assign({ id: 'bar' }, tu, uv);
|
||||
var result = __assign({}, tu, uv, { id: 'bar' });
|
||||
var expected;
|
||||
var assignable = result;
|
||||
}
|
||||
|
||||
@ -46,26 +46,26 @@ function tripleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 8, 23))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 8, 26))
|
||||
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let result = { ...tuv, id: 'foo' };
|
||||
>result : Symbol(result, Decl(objectSpreadUnion.ts, 10, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 10, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 10, 26))
|
||||
|
||||
let expected: { id: string, ...T } | { id: string, ...U } | { id: string, ...V } = result;
|
||||
let expected: { ...T, id: string } | { ...U, id: string } | { ...V, id: string } = result;
|
||||
>expected : Symbol(expected, Decl(objectSpreadUnion.ts, 11, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 19))
|
||||
>T : Symbol(T, Decl(objectSpreadUnion.ts, 8, 21))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 42))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 25))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 8, 23))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 65))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 48))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 8, 26))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 11, 71))
|
||||
>result : Symbol(result, Decl(objectSpreadUnion.ts, 10, 7))
|
||||
|
||||
let assignable: { id: string, ...(T | U | V) } = result;
|
||||
let assignable: { ...(T | U | V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadUnion.ts, 12, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 12, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadUnion.ts, 8, 21))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 8, 23))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 8, 26))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 12, 37))
|
||||
>result : Symbol(result, Decl(objectSpreadUnion.ts, 10, 7))
|
||||
}
|
||||
function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
@ -90,31 +90,31 @@ function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 14, 34))
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let result = { ...tu, ...uv, id: 'bar' };
|
||||
>result : Symbol(result, Decl(objectSpreadUnion.ts, 17, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 17, 18))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 17, 32))
|
||||
|
||||
let expected: { id: string, ...T, ...U } | { id: string, ...T, ...V } | { id: string, ...U } | { id: string, ...U, ...V };
|
||||
let expected: { ...T, ...U, id: string } | { ...T, ...V, id: string } | { ...U, id: string } | { ...U, ...V, id: string };
|
||||
>expected : Symbol(expected, Decl(objectSpreadUnion.ts, 18, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 19))
|
||||
>T : Symbol(T, Decl(objectSpreadUnion.ts, 14, 29))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 48))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 31))
|
||||
>T : Symbol(T, Decl(objectSpreadUnion.ts, 14, 29))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 14, 34))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 77))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 60))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 100))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 83))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 14, 34))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 18, 112))
|
||||
|
||||
let assignable: { id: string, ...(T | U), ...(U | V) } = result;
|
||||
let assignable: { ...(T | U), ...(U | V), id: string } = result;
|
||||
>assignable : Symbol(assignable, Decl(objectSpreadUnion.ts, 19, 7))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 19, 21))
|
||||
>T : Symbol(T, Decl(objectSpreadUnion.ts, 14, 29))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>U : Symbol(U, Decl(objectSpreadUnion.ts, 14, 31))
|
||||
>V : Symbol(V, Decl(objectSpreadUnion.ts, 14, 34))
|
||||
>id : Symbol(id, Decl(objectSpreadUnion.ts, 19, 45))
|
||||
>result : Symbol(result, Decl(objectSpreadUnion.ts, 17, 7))
|
||||
}
|
||||
|
||||
|
||||
@ -48,30 +48,30 @@ function tripleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'foo', ...tuv };
|
||||
>result : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
>{ id: 'foo', ...tuv } : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
let result = { ...tuv, id: 'foo' };
|
||||
>result : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
>{ ...tuv, id: 'foo' } : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
>tuv : any
|
||||
>id : string
|
||||
>'foo' : "foo"
|
||||
>tuv : any
|
||||
|
||||
let expected: { id: string, ...T } | { id: string, ...U } | { id: string, ...V } = result;
|
||||
>expected : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
>id : string
|
||||
let expected: { ...T, id: string } | { ...U, id: string } | { ...V, id: string } = result;
|
||||
>expected : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
>T : T
|
||||
>id : string
|
||||
>U : U
|
||||
>id : string
|
||||
>V : V
|
||||
>result : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
|
||||
let assignable: { id: string, ...(T | U | V) } = result;
|
||||
>assignable : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
>id : string
|
||||
>result : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
|
||||
let assignable: { ...(T | U | V), id: string } = result;
|
||||
>assignable : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>V : V
|
||||
>result : { id: string; ...T } | { id: string; ...U } | { id: string; ...V }
|
||||
>id : string
|
||||
>result : { ...T; id: string; } | { ...U; id: string; } | { ...V; id: string; }
|
||||
}
|
||||
function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>iteratedDoubleUnion : <T, U, V>(t: T, u: U, v: V) => void
|
||||
@ -95,17 +95,16 @@ function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>U : U
|
||||
>V : V
|
||||
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
>result : { id: string; ...T; ...U } | { id: string; ...U } | { id: string; ...T; ...V } | { id: string; ...U; ...V }
|
||||
>{ id: 'bar', ...tu, ...uv } : { id: string; ...T; ...U } | { id: string; ...U } | { id: string; ...T; ...V } | { id: string; ...U; ...V }
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
let result = { ...tu, ...uv, id: 'bar' };
|
||||
>result : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; }
|
||||
>{ ...tu, ...uv, id: 'bar' } : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; }
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
>'bar' : "bar"
|
||||
|
||||
let expected: { id: string, ...T, ...U } | { id: string, ...T, ...V } | { id: string, ...U } | { id: string, ...U, ...V };
|
||||
>expected : { id: string; ...T; ...U } | { id: string; ...T; ...V } | { id: string; ...U } | { id: string; ...U; ...V }
|
||||
>id : string
|
||||
let expected: { ...T, ...U, id: string } | { ...T, ...V, id: string } | { ...U, id: string } | { ...U, ...V, id: string };
|
||||
>expected : { ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; id: string; } | { ...U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>id : string
|
||||
@ -116,15 +115,16 @@ function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
>id : string
|
||||
>U : U
|
||||
>V : V
|
||||
>id : string
|
||||
|
||||
let assignable: { id: string, ...(T | U), ...(U | V) } = result;
|
||||
>assignable : { id: string; ...T; ...U } | { id: string; ...U } | { id: string; ...T; ...V } | { id: string; ...U; ...V }
|
||||
>id : string
|
||||
let assignable: { ...(T | U), ...(U | V), id: string } = result;
|
||||
>assignable : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : V
|
||||
>result : { id: string; ...T; ...U } | { id: string; ...U } | { id: string; ...T; ...V } | { id: string; ...U; ...V }
|
||||
>id : string
|
||||
>result : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...U; ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...T; ...V; id: string; } | { ...U; ...V; id: string; } | { ...T; ...U; ...V; id: string; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -83,8 +83,8 @@ let a = 12;
|
||||
let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
|
||||
// generics
|
||||
function f<T, U>(t: T, u: U): { id: string, ...T, ...U } {
|
||||
return { id: 'id', ...t, ...u };
|
||||
function f<T, U>(t: T, u: U): { ...T, ...U, id: string } {
|
||||
return { ...t, ...u, id: 'id' };
|
||||
}
|
||||
let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
f({ a: 1, b: 'yes' }, { c: 'no', d: false })
|
||||
@ -92,7 +92,7 @@ let overlap: { id: string, a: number, b: string } =
|
||||
f({ a: 1 }, { a: 2, b: 'extra' })
|
||||
let overlapConflict: { id:string, a: string } =
|
||||
f({ a: 1 }, { a: 'mismatch' })
|
||||
let overwriteId: { id: boolean, a: number, c: number, d: string } =
|
||||
let overwriteId: { id: string, a: number, c: number, d: string } =
|
||||
f({ a: 1, id: true }, { c: 1, d: 'no' })
|
||||
|
||||
class D { m() { }; q = 2; }
|
||||
|
||||
@ -13,34 +13,36 @@ function f<T, U, V>(t: T, u: U, v: V): void {
|
||||
const missingU: { ...T, ...V } = o; // error, missing U
|
||||
const missingV: { ...T, ...U } = o; // error, missing V
|
||||
const atEnd: { ...T, ...U, second: string } = { ...t, ...u, second: 'foo' }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // ok
|
||||
const atBeginning: { first: string, ...T, ...U, } = { first: 'foo', ...t, ...u }; // error, not assignable
|
||||
|
||||
const emptyTarget: { } = { ...t, ...u } // ok
|
||||
const emptySource: { ...T, ...U } = { }; // error, {} is not assignable to U (or T)
|
||||
|
||||
// error, { sn?: boolean } ...T ... { sn?: number | string } is not assignable to
|
||||
// T ... { sn?: number | string | boolean }
|
||||
let optionalNumber: { sn?: number };
|
||||
let optionalString: { sn?: string };
|
||||
let optionalBoolean: { sn?: boolean };
|
||||
const unionCutoff: { ...T, sn?: number | string | boolean } =
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber } // ok
|
||||
{ ...optionalBoolean, ...t, ...optionalString, ...optionalNumber }
|
||||
unionCutoff.sn; // ok
|
||||
const optionalCutoff = { ...t, ...optionalNumber }; // ok
|
||||
optionalCutoff.sn; // ok
|
||||
|
||||
const interspersed: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const interspersedMissingU: { first: string, second: string, ...T, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3' }; // error, 'U' is missing
|
||||
const interspersedOrder1: { first: string, ...T, second: string, ...U, third: string, secondsecond: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
const interspersedOrder2: { first: string, second: string, secondsecond: string, third: string, ...T, ...U } =
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // ok
|
||||
{ first: '1', ...t, second: '2', ...u, third: '3', secondsecond: 'false' }; // error, not assignable
|
||||
|
||||
|
||||
const mismatchFirst: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, 'first' not found
|
||||
{ firrrrrrst: '1', ...t, second: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchSecond: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, 'second' not found
|
||||
{ first: '1', ...t, ssssssssecond: '2', ...u, third: '3' }; // error, not assignable
|
||||
const mismatchLast: { first: string, ...T, second: string, ...U, third: string } =
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, 'third' not found
|
||||
{ first: '1', ...t, second: '2', ...u, thirrrrrrrd: '3' }; // error, not assignable
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
function iteratedUnionIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T | U;
|
||||
let uv: U & V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...T, ...V }) | ({ id: string, ...U } & { id: string, ...U, ...V });
|
||||
let assignable: { id: string, ...(T | U), ...(U & V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'foo' };
|
||||
let expected: ({ ...T, ...U, id: string } & { ...T, ...V, id: string }) | ({ ...U, id: string } & { ...U, ...V, id: string });
|
||||
let assignable: { ...(T | U), ...(U & V), id: string } = result;
|
||||
}
|
||||
// concrete types work
|
||||
interface A1 { a: number }
|
||||
@ -15,22 +15,22 @@ let assignable: { ...(A1 & A2) } = result;
|
||||
|
||||
function tripleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tuv: T & U & V;
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let expected: { id: string, ...T } & { id: string, ...U } & { id: string, ...V } = result;
|
||||
let assignable: { id: string, ...(T & U & V) } = result;
|
||||
let result = { ...tuv, id: 'bar' };
|
||||
let expected: { ...T, id: string } & { ...U, id: string } & { ...V, id: string } = result;
|
||||
let assignable: { ...(T & U & V), id: string } = result;
|
||||
}
|
||||
function iteratedDoubleIntersection<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T & U;
|
||||
let uv: U & V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: { id: string, ...T, ...U } & { id: string, ...T, ...V } & { id: string, ...U } & { id: string, ...U, ...V };
|
||||
let assignable: { id: string, ...(T & U), ...(U & V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'baz' };
|
||||
let expected: { ...T, ...U, id: string } & { ...T, ...V, id: string } & { ...U, id: string } & { ...U, ...V, id: string };
|
||||
let assignable: { ...(T & U), ...(U & V), id: string } = result;
|
||||
}
|
||||
function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T & U;
|
||||
let uv: U | V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: ({ id: string, ...T, ...U } & { id: string, ...U }) | ({ id: string, ...T, ...V } & { id: string, ...U, ...V });
|
||||
let assignable: { id: string, ...(T & U), ...(U | V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'qux' };
|
||||
let expected: ({ ...T, ...U, id: string } & { ...U, id: string }) | ({ ...T, ...V, id: string } & { ...U, ...V, id: string });
|
||||
let assignable: { ...(T & U), ...(U | V), id: string } = result;
|
||||
}
|
||||
|
||||
|
||||
@ -8,16 +8,16 @@ let assignable: { ...(A1 | A2) } = result;
|
||||
|
||||
function tripleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tuv: T | U | V;
|
||||
let result = { id: 'foo', ...tuv };
|
||||
let expected: { id: string, ...T } | { id: string, ...U } | { id: string, ...V } = result;
|
||||
let assignable: { id: string, ...(T | U | V) } = result;
|
||||
let result = { ...tuv, id: 'foo' };
|
||||
let expected: { ...T, id: string } | { ...U, id: string } | { ...V, id: string } = result;
|
||||
let assignable: { ...(T | U | V), id: string } = result;
|
||||
}
|
||||
function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
||||
let tu: T | U;
|
||||
let uv: U | V;
|
||||
let result = { id: 'bar', ...tu, ...uv };
|
||||
let expected: { id: string, ...T, ...U } | { id: string, ...T, ...V } | { id: string, ...U } | { id: string, ...U, ...V };
|
||||
let assignable: { id: string, ...(T | U), ...(U | V) } = result;
|
||||
let result = { ...tu, ...uv, id: 'bar' };
|
||||
let expected: { ...T, ...U, id: string } | { ...T, ...V, id: string } | { ...U, id: string } | { ...U, ...V, id: string };
|
||||
let assignable: { ...(T | U), ...(U | V), id: string } = result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user