Update baselines with new index signature rules
This commit is contained in:
parent
fdfb159024
commit
ff92afd47b
|
@ -35,14 +35,12 @@ let getter: { a: number, c: number } =
|
|||
{ ...op, c: 7 }
|
||||
getter.a = 12;
|
||||
|
||||
// null, undefined, functions and primitives besides string result in { }
|
||||
// null, undefined, functions and primitives result in { }
|
||||
let spreadNull = { ...null };
|
||||
let spreadUndefind = { ...undefined };
|
||||
let spreadNum = { ...12 };
|
||||
let spreadBool = { ...false };
|
||||
let spreadFunc = { ...(function () { }) };
|
||||
|
||||
// strings get a numeric indexer: [n: number]: string
|
||||
let spreadStr = { ...'foo' };
|
||||
|
||||
// methods are not enumerable
|
||||
|
@ -130,13 +128,12 @@ var propertyNested = __assign({ a: __assign({}, o) });
|
|||
var op = { get a() { return 6; } };
|
||||
var getter = __assign({}, op, { c: 7 });
|
||||
getter.a = 12;
|
||||
// null, undefined, functions and primitives besides string result in { }
|
||||
// null, undefined, functions and primitives result in { }
|
||||
var spreadNull = __assign({}, null);
|
||||
var spreadUndefind = __assign({}, undefined);
|
||||
var spreadNum = __assign({}, 12);
|
||||
var spreadBool = __assign({}, false);
|
||||
var spreadFunc = __assign({}, (function () { }));
|
||||
// strings get a numeric indexer: [n: number]: string
|
||||
var spreadStr = __assign({}, 'foo');
|
||||
// methods are not enumerable
|
||||
var C = (function () {
|
||||
|
|
|
@ -150,7 +150,7 @@ getter.a = 12;
|
|||
>getter : Symbol(getter, Decl(objectSpread.ts, 32, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 32, 13))
|
||||
|
||||
// null, undefined, functions and primitives besides string result in { }
|
||||
// null, undefined, functions and primitives result in { }
|
||||
let spreadNull = { ...null };
|
||||
>spreadNull : Symbol(spreadNull, Decl(objectSpread.ts, 37, 3))
|
||||
|
||||
|
@ -166,209 +166,208 @@ let spreadBool = { ...false };
|
|||
let spreadFunc = { ...(function () { }) };
|
||||
>spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 41, 3))
|
||||
|
||||
// strings get a numeric indexer: [n: number]: string
|
||||
let spreadStr = { ...'foo' };
|
||||
>spreadStr : Symbol(spreadStr, Decl(objectSpread.ts, 44, 3))
|
||||
>spreadStr : Symbol(spreadStr, Decl(objectSpread.ts, 42, 3))
|
||||
|
||||
// methods are not enumerable
|
||||
class C { p = 1; m() { } }
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 44, 29))
|
||||
>p : Symbol(C.p, Decl(objectSpread.ts, 47, 9))
|
||||
>m : Symbol(C.m, Decl(objectSpread.ts, 47, 16))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 42, 29))
|
||||
>p : Symbol(C.p, Decl(objectSpread.ts, 45, 9))
|
||||
>m : Symbol(C.m, Decl(objectSpread.ts, 45, 16))
|
||||
|
||||
let c: C = new C()
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 48, 3))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 44, 29))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 44, 29))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 46, 3))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 42, 29))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 42, 29))
|
||||
|
||||
let spreadC: { p: number } = { ...c }
|
||||
>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 49, 3))
|
||||
>p : Symbol(p, Decl(objectSpread.ts, 49, 14))
|
||||
>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 47, 3))
|
||||
>p : Symbol(p, Decl(objectSpread.ts, 47, 14))
|
||||
|
||||
// own methods are enumerable
|
||||
let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } };
|
||||
>cplus : Symbol(cplus, Decl(objectSpread.ts, 52, 3))
|
||||
>p : Symbol(p, Decl(objectSpread.ts, 52, 12))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 52, 23))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 52, 48))
|
||||
>cplus : Symbol(cplus, Decl(objectSpread.ts, 50, 3))
|
||||
>p : Symbol(p, Decl(objectSpread.ts, 50, 12))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 50, 23))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 50, 48))
|
||||
|
||||
cplus.plus();
|
||||
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 52, 23))
|
||||
>cplus : Symbol(cplus, Decl(objectSpread.ts, 52, 3))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 52, 23))
|
||||
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 50, 23))
|
||||
>cplus : Symbol(cplus, Decl(objectSpread.ts, 50, 3))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 50, 23))
|
||||
|
||||
// new field's type conflicting with existing field is OK
|
||||
let changeTypeAfter: { a: string, b: string } =
|
||||
>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 56, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 56, 22))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 56, 33))
|
||||
>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 54, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 54, 22))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 54, 33))
|
||||
|
||||
{ ...o, a: 'wrong type?' }
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 57, 11))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 55, 11))
|
||||
|
||||
let changeTypeBefore: { a: number, b: string } =
|
||||
>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 58, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 58, 23))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 58, 34))
|
||||
>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 56, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 56, 23))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 56, 34))
|
||||
|
||||
{ a: 'wrong type?', ...o };
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 59, 5))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 57, 5))
|
||||
|
||||
let changeTypeBoth: { a: string, b: number } =
|
||||
>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 60, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 60, 21))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 60, 32))
|
||||
>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 58, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 58, 21))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 58, 32))
|
||||
|
||||
{ ...o, ...swap };
|
||||
|
||||
// optional
|
||||
let definiteBoolean: { sn: boolean };
|
||||
>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 64, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 64, 22))
|
||||
>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 62, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 62, 22))
|
||||
|
||||
let definiteString: { sn: string };
|
||||
>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 65, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 65, 21))
|
||||
>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 63, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 63, 21))
|
||||
|
||||
let optionalString: { sn?: string };
|
||||
>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 66, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 66, 21))
|
||||
>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 64, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 64, 21))
|
||||
|
||||
let optionalNumber: { sn?: number };
|
||||
>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 67, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 67, 21))
|
||||
>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 65, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 65, 21))
|
||||
|
||||
let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber };
|
||||
>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 68, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 68, 25))
|
||||
>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 66, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 66, 25))
|
||||
|
||||
let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber };
|
||||
>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 69, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 69, 30))
|
||||
>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 67, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 67, 30))
|
||||
|
||||
let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber };
|
||||
>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 70, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 70, 18))
|
||||
>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 68, 3))
|
||||
>sn : Symbol(sn, Decl(objectSpread.ts, 68, 18))
|
||||
|
||||
// computed property
|
||||
let computedFirst: { a: number, b: string, "before everything": number } =
|
||||
>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 73, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 73, 20))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 73, 31))
|
||||
>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 71, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 71, 20))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 71, 31))
|
||||
|
||||
{ ['before everything']: 12, ...o, b: 'yes' }
|
||||
>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 74, 5))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 74, 38))
|
||||
>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 72, 5))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 72, 38))
|
||||
|
||||
let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } =
|
||||
>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 75, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 75, 21))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 75, 32))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 75, 43))
|
||||
>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 73, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 73, 21))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 73, 32))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 73, 43))
|
||||
|
||||
{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 }
|
||||
>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 76, 11))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 76, 34))
|
||||
>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 74, 11))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 74, 34))
|
||||
|
||||
let computedAfter: { a: number, b: string, "at the end": number } =
|
||||
>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 77, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 77, 20))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 77, 31))
|
||||
>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 75, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 75, 20))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 75, 31))
|
||||
|
||||
{ ...o, b: 'yeah', ['at the end']: 14 }
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 78, 11))
|
||||
>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 78, 22))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 76, 11))
|
||||
>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 76, 22))
|
||||
|
||||
// shortcut syntax
|
||||
let a = 12;
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 80, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 78, 3))
|
||||
|
||||
let shortCutted: { a: number, b: string } = { ...o, a }
|
||||
>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 81, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 81, 18))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 81, 29))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 81, 51))
|
||||
>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 79, 3))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 79, 18))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 79, 29))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 79, 51))
|
||||
|
||||
// generics
|
||||
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))
|
||||
>t : Symbol(t, Decl(objectSpread.ts, 84, 17))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 84, 11))
|
||||
>u : Symbol(u, Decl(objectSpread.ts, 84, 22))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 84, 13))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 84, 11))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 84, 13))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 84, 43))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 82, 11))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 82, 13))
|
||||
>t : Symbol(t, Decl(objectSpread.ts, 82, 17))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 82, 11))
|
||||
>u : Symbol(u, Decl(objectSpread.ts, 82, 22))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 82, 13))
|
||||
>T : Symbol(T, Decl(objectSpread.ts, 82, 11))
|
||||
>U : Symbol(U, Decl(objectSpread.ts, 82, 13))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 82, 43))
|
||||
|
||||
return { ...t, ...u, id: 'id' };
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 85, 24))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 83, 24))
|
||||
}
|
||||
let exclusive: { id: string, a: number, b: string, c: string, d: boolean } =
|
||||
>exclusive : Symbol(exclusive, Decl(objectSpread.ts, 87, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 87, 16))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 87, 28))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 87, 39))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 87, 50))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 87, 61))
|
||||
>exclusive : Symbol(exclusive, Decl(objectSpread.ts, 85, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 85, 16))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 85, 28))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 85, 39))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 85, 50))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 85, 61))
|
||||
|
||||
f({ a: 1, b: 'yes' }, { c: 'no', d: false })
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 88, 7))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 88, 13))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 88, 27))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 88, 36))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 86, 7))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 86, 13))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 86, 27))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 86, 36))
|
||||
|
||||
let overlap: { id: string, a: number, b: string } =
|
||||
>overlap : Symbol(overlap, Decl(objectSpread.ts, 89, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 89, 14))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 89, 26))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 89, 37))
|
||||
>overlap : Symbol(overlap, Decl(objectSpread.ts, 87, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 87, 14))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 87, 26))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 87, 37))
|
||||
|
||||
f({ a: 1 }, { a: 2, b: 'extra' })
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 90, 7))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 90, 17))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 90, 23))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 88, 7))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 88, 17))
|
||||
>b : Symbol(b, Decl(objectSpread.ts, 88, 23))
|
||||
|
||||
let overlapConflict: { id:string, a: string } =
|
||||
>overlapConflict : Symbol(overlapConflict, Decl(objectSpread.ts, 91, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 91, 22))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 91, 33))
|
||||
>overlapConflict : Symbol(overlapConflict, Decl(objectSpread.ts, 89, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 89, 22))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 89, 33))
|
||||
|
||||
f({ a: 1 }, { a: 'mismatch' })
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 92, 7))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 92, 17))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 90, 7))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 90, 17))
|
||||
|
||||
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, 30))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 93, 41))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 93, 52))
|
||||
>overwriteId : Symbol(overwriteId, Decl(objectSpread.ts, 91, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 91, 18))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 91, 30))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 91, 41))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 91, 52))
|
||||
|
||||
f({ a: 1, id: true }, { c: 1, d: 'no' })
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 94, 7))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 94, 13))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 94, 27))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 94, 33))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>a : Symbol(a, Decl(objectSpread.ts, 92, 7))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 92, 13))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 92, 27))
|
||||
>d : Symbol(d, Decl(objectSpread.ts, 92, 33))
|
||||
|
||||
class D { m() { }; q = 2; }
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 94, 44))
|
||||
>m : Symbol(D.m, Decl(objectSpread.ts, 96, 9))
|
||||
>q : Symbol(D.q, Decl(objectSpread.ts, 96, 18))
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 92, 44))
|
||||
>m : Symbol(D.m, Decl(objectSpread.ts, 94, 9))
|
||||
>q : Symbol(D.q, Decl(objectSpread.ts, 94, 18))
|
||||
|
||||
let classesAreWrong: { id: string, ...C, ...D } =
|
||||
>classesAreWrong : Symbol(classesAreWrong, Decl(objectSpread.ts, 97, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 97, 22))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 44, 29))
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 94, 44))
|
||||
>classesAreWrong : Symbol(classesAreWrong, Decl(objectSpread.ts, 95, 3))
|
||||
>id : Symbol(id, Decl(objectSpread.ts, 95, 22))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 42, 29))
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 92, 44))
|
||||
|
||||
f(new C(), new D())
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 81, 55))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 44, 29))
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 94, 44))
|
||||
>f : Symbol(f, Decl(objectSpread.ts, 79, 55))
|
||||
>C : Symbol(C, Decl(objectSpread.ts, 42, 29))
|
||||
>D : Symbol(D, Decl(objectSpread.ts, 92, 44))
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ getter.a = 12;
|
|||
>a : number
|
||||
>12 : 12
|
||||
|
||||
// null, undefined, functions and primitives besides string result in { }
|
||||
// null, undefined, functions and primitives result in { }
|
||||
let spreadNull = { ...null };
|
||||
>spreadNull : {}
|
||||
>{ ...null } : {}
|
||||
|
@ -249,10 +249,9 @@ let spreadFunc = { ...(function () { }) };
|
|||
>(function () { }) : () => void
|
||||
>function () { } : () => void
|
||||
|
||||
// strings get a numeric indexer: [n: number]: string
|
||||
let spreadStr = { ...'foo' };
|
||||
>spreadStr : { [x: number]: string; }
|
||||
>{ ...'foo' } : { [x: number]: string; }
|
||||
>spreadStr : {}
|
||||
>{ ...'foo' } : {}
|
||||
|
||||
// methods are not enumerable
|
||||
class C { p = 1; m() { } }
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts(6,39): error TS2698: Type literals with spreads cannot contain an index signature.
|
||||
tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts(24,20): error TS2698: Type literals with spreads cannot contain an index signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts (2 errors) ====
|
||||
class C {
|
||||
a: number;
|
||||
c: boolean;
|
||||
}
|
||||
// index signatures are not allowed in object literals with spread types
|
||||
let c: { ...C, b: string, c?: string, [n: number]: string };
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Type literals with spreads cannot contain an index signature.
|
||||
let n: number = c.a;
|
||||
let s: string = c[12];
|
||||
interface Indexed {
|
||||
[n: string]: number;
|
||||
a: number;
|
||||
}
|
||||
let i: { ...Indexed, b: number };
|
||||
n = i[101];
|
||||
n = i.b;
|
||||
interface Indexed2 {
|
||||
[n: string]: boolean;
|
||||
c: boolean;
|
||||
}
|
||||
let ii: { ...Indexed, ...Indexed2, b: boolean, d: number };
|
||||
let nb: number | boolean = ii[1001];
|
||||
|
||||
function f<T>(t: T) {
|
||||
let i: { ...T, [n: number]: string };
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2698: Type literals with spreads cannot contain an index signature.
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ class C {
|
|||
a: number;
|
||||
c: boolean;
|
||||
}
|
||||
// index signatures are not allowed in object literals with spread types
|
||||
let c: { ...C, b: string, c?: string, [n: number]: string };
|
||||
let n: number = c.a;
|
||||
let s: string = c[12];
|
||||
|
@ -31,6 +32,7 @@ var C = (function () {
|
|||
}
|
||||
return C;
|
||||
}());
|
||||
// index signatures are not allowed in object literals with spread types
|
||||
var c;
|
||||
var n = c.a;
|
||||
var s = c[12];
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
=== tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(objectSpreadIndexSignature.ts, 0, 0))
|
||||
|
||||
a: number;
|
||||
>a : Symbol(C.a, Decl(objectSpreadIndexSignature.ts, 0, 9))
|
||||
|
||||
c: boolean;
|
||||
>c : Symbol(C.c, Decl(objectSpreadIndexSignature.ts, 1, 14))
|
||||
}
|
||||
let c: { ...C, b: string, c?: string, [n: number]: string };
|
||||
>c : Symbol(c, Decl(objectSpreadIndexSignature.ts, 4, 3))
|
||||
>C : Symbol(C, Decl(objectSpreadIndexSignature.ts, 0, 0))
|
||||
>b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 4, 14))
|
||||
>c : Symbol(c, Decl(objectSpreadIndexSignature.ts, 4, 25))
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 4, 39))
|
||||
|
||||
let n: number = c.a;
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 5, 3))
|
||||
>c.a : Symbol(C.a, Decl(objectSpreadIndexSignature.ts, 0, 9))
|
||||
>c : Symbol(c, Decl(objectSpreadIndexSignature.ts, 4, 3))
|
||||
>a : Symbol(C.a, Decl(objectSpreadIndexSignature.ts, 0, 9))
|
||||
|
||||
let s: string = c[12];
|
||||
>s : Symbol(s, Decl(objectSpreadIndexSignature.ts, 6, 3))
|
||||
>c : Symbol(c, Decl(objectSpreadIndexSignature.ts, 4, 3))
|
||||
|
||||
interface Indexed {
|
||||
>Indexed : Symbol(Indexed, Decl(objectSpreadIndexSignature.ts, 6, 22))
|
||||
|
||||
[n: string]: number;
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 8, 5))
|
||||
|
||||
a: number;
|
||||
>a : Symbol(Indexed.a, Decl(objectSpreadIndexSignature.ts, 8, 24))
|
||||
}
|
||||
let i: { ...Indexed, b: number };
|
||||
>i : Symbol(i, Decl(objectSpreadIndexSignature.ts, 11, 3))
|
||||
>Indexed : Symbol(Indexed, Decl(objectSpreadIndexSignature.ts, 6, 22))
|
||||
>b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 11, 20))
|
||||
|
||||
n = i[101];
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 5, 3))
|
||||
>i : Symbol(i, Decl(objectSpreadIndexSignature.ts, 11, 3))
|
||||
|
||||
n = i.b;
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 5, 3))
|
||||
>i.b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 11, 20))
|
||||
>i : Symbol(i, Decl(objectSpreadIndexSignature.ts, 11, 3))
|
||||
>b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 11, 20))
|
||||
|
||||
interface Indexed2 {
|
||||
>Indexed2 : Symbol(Indexed2, Decl(objectSpreadIndexSignature.ts, 13, 8))
|
||||
|
||||
[n: string]: boolean;
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 15, 5))
|
||||
|
||||
c: boolean;
|
||||
>c : Symbol(Indexed2.c, Decl(objectSpreadIndexSignature.ts, 15, 25))
|
||||
}
|
||||
let ii: { ...Indexed, ...Indexed2, b: boolean, d: number };
|
||||
>ii : Symbol(ii, Decl(objectSpreadIndexSignature.ts, 18, 3))
|
||||
>Indexed : Symbol(Indexed, Decl(objectSpreadIndexSignature.ts, 6, 22))
|
||||
>Indexed2 : Symbol(Indexed2, Decl(objectSpreadIndexSignature.ts, 13, 8))
|
||||
>b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 18, 34))
|
||||
>d : Symbol(d, Decl(objectSpreadIndexSignature.ts, 18, 46))
|
||||
|
||||
let nb: number | boolean = ii[1001];
|
||||
>nb : Symbol(nb, Decl(objectSpreadIndexSignature.ts, 19, 3))
|
||||
>ii : Symbol(ii, Decl(objectSpreadIndexSignature.ts, 18, 3))
|
||||
|
||||
function f<T>(t: T) {
|
||||
>f : Symbol(f, Decl(objectSpreadIndexSignature.ts, 19, 36))
|
||||
>T : Symbol(T, Decl(objectSpreadIndexSignature.ts, 21, 11))
|
||||
>t : Symbol(t, Decl(objectSpreadIndexSignature.ts, 21, 14))
|
||||
>T : Symbol(T, Decl(objectSpreadIndexSignature.ts, 21, 11))
|
||||
|
||||
let i: { ...T, [n: number]: string };
|
||||
>i : Symbol(i, Decl(objectSpreadIndexSignature.ts, 22, 7))
|
||||
>T : Symbol(T, Decl(objectSpreadIndexSignature.ts, 21, 11))
|
||||
>n : Symbol(n, Decl(objectSpreadIndexSignature.ts, 22, 20))
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
=== tests/cases/conformance/types/spread/objectSpreadIndexSignature.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
a: number;
|
||||
>a : number
|
||||
|
||||
c: boolean;
|
||||
>c : boolean
|
||||
}
|
||||
let c: { ...C, b: string, c?: string, [n: number]: string };
|
||||
>c : { [x: number]: string; b: string; c: string | boolean; a: number; }
|
||||
>C : C
|
||||
>b : string
|
||||
>c : string
|
||||
>n : number
|
||||
|
||||
let n: number = c.a;
|
||||
>n : number
|
||||
>c.a : number
|
||||
>c : { [x: number]: string; b: string; c: string | boolean; a: number; }
|
||||
>a : number
|
||||
|
||||
let s: string = c[12];
|
||||
>s : string
|
||||
>c[12] : string
|
||||
>c : { [x: number]: string; b: string; c: string | boolean; a: number; }
|
||||
>12 : 12
|
||||
|
||||
interface Indexed {
|
||||
>Indexed : Indexed
|
||||
|
||||
[n: string]: number;
|
||||
>n : string
|
||||
|
||||
a: number;
|
||||
>a : number
|
||||
}
|
||||
let i: { ...Indexed, b: number };
|
||||
>i : { [n: string]: number; b: number; a: number; }
|
||||
>Indexed : Indexed
|
||||
>b : number
|
||||
|
||||
n = i[101];
|
||||
>n = i[101] : number
|
||||
>n : number
|
||||
>i[101] : number
|
||||
>i : { [n: string]: number; b: number; a: number; }
|
||||
>101 : 101
|
||||
|
||||
n = i.b;
|
||||
>n = i.b : number
|
||||
>n : number
|
||||
>i.b : number
|
||||
>i : { [n: string]: number; b: number; a: number; }
|
||||
>b : number
|
||||
|
||||
interface Indexed2 {
|
||||
>Indexed2 : Indexed2
|
||||
|
||||
[n: string]: boolean;
|
||||
>n : string
|
||||
|
||||
c: boolean;
|
||||
>c : boolean
|
||||
}
|
||||
let ii: { ...Indexed, ...Indexed2, b: boolean, d: number };
|
||||
>ii : { [x: string]: number | boolean; b: boolean; d: number; c: boolean; a: number; }
|
||||
>Indexed : Indexed
|
||||
>Indexed2 : Indexed2
|
||||
>b : boolean
|
||||
>d : number
|
||||
|
||||
let nb: number | boolean = ii[1001];
|
||||
>nb : number | boolean
|
||||
>ii[1001] : number | boolean
|
||||
>ii : { [x: string]: number | boolean; b: boolean; d: number; c: boolean; a: number; }
|
||||
>1001 : 1001
|
||||
|
||||
function f<T>(t: T) {
|
||||
>f : <T>(t: T) => void
|
||||
>T : T
|
||||
>t : T
|
||||
>T : T
|
||||
|
||||
let i: { ...T, [n: number]: string };
|
||||
>i : { ...T; [n: number]: string; }
|
||||
>T : T
|
||||
>n : number
|
||||
}
|
||||
|
|
@ -187,21 +187,21 @@ function iteratedIntersectionUnion<T, U, V>(t: T, u: U, v: V): void {
|
|||
>V : V
|
||||
|
||||
let result = { ...tu, ...uv, id: 'qux' };
|
||||
>result : { ...T & U; ...T & U; ...U; id: string; } | { ...T & U; ...T & U; ...V; id: string; }
|
||||
>{ ...tu, ...uv, id: 'qux' } : { ...T & U; ...T & U; ...U; id: string; } | { ...T & U; ...T & U; ...V; id: string; }
|
||||
>result : { ...T & U; ...U; id: string; } | { ...T & U; ...V; id: string; }
|
||||
>{ ...tu, ...uv, id: 'qux' } : { ...T & U; ...U; id: string; } | { ...T & U; ...V; id: string; }
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
>'qux' : "qux"
|
||||
|
||||
let assignable: { ...(T & U), ...(U | V), id: string } = result;
|
||||
>assignable : { ...T & U; ...T & U; ...U; id: string; } | { ...T & U; ...T & U; ...V; id: string; }
|
||||
>assignable : { ...T & U; ...U; id: string; } | { ...T & U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : V
|
||||
>id : string
|
||||
>result : { ...T & U; ...T & U; ...U; id: string; } | { ...T & U; ...T & U; ...V; id: string; }
|
||||
>result : { ...T & U; ...U; id: string; } | { ...T & U; ...V; id: string; }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(30,12): error TS233
|
|||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,17): error TS2339: Property 'undefined' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'toFixed' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(38,11): error TS2339: Property 'toFixed' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(40,11): error TS2339: Property 'length' does not exist on type '{ [x: number]: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,11): error TS2339: Property 'charAt' does not exist on type '{ [x: number]: string; }'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(40,11): error TS2339: Property 'length' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,11): error TS2339: Property 'charAt' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(45,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,12): error TS2339: Property 'b' does not exist on type '{}'.
|
||||
tests/cases/conformance/types/spread/objectSpreadNegative.ts(55,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'.
|
||||
|
@ -87,10 +87,10 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(66,12): error TS232
|
|||
let spreadStr = { ...'foo' };
|
||||
spreadStr.length; // error, no 'length'
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'length' does not exist on type '{ [x: number]: string; }'.
|
||||
!!! error TS2339: Property 'length' does not exist on type '{}'.
|
||||
spreadStr.charAt(1); // error, no methods either
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'charAt' does not exist on type '{ [x: number]: string; }'.
|
||||
!!! error TS2339: Property 'charAt' does not exist on type '{}'.
|
||||
let spreadBool = { ...true };
|
||||
spreadBool.valueOf(); // error, what were you thinking?
|
||||
let spreadFunc = { ...function () { } }
|
||||
|
|
|
@ -96,8 +96,8 @@ function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
|||
>V : V
|
||||
|
||||
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; }
|
||||
>result : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...V; id: string; }
|
||||
>{ ...tu, ...uv, id: 'bar' } : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...V; id: string; }
|
||||
>tu : any
|
||||
>uv : any
|
||||
>id : string
|
||||
|
@ -118,13 +118,13 @@ function iteratedDoubleUnion<T, U, V>(t: T, u: U, v: V): void {
|
|||
>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; }
|
||||
>assignable : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...V; id: string; }
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
>V : 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; }
|
||||
>result : { ...U; id: string; } | { ...T; ...U; id: string; } | { ...T; ...V; id: string; } | { ...U; ...V; id: string; }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,14 +35,12 @@ let getter: { a: number, c: number } =
|
|||
{ ...op, c: 7 }
|
||||
getter.a = 12;
|
||||
|
||||
// null, undefined, functions and primitives besides string result in { }
|
||||
// null, undefined, functions and primitives result in { }
|
||||
let spreadNull = { ...null };
|
||||
let spreadUndefind = { ...undefined };
|
||||
let spreadNum = { ...12 };
|
||||
let spreadBool = { ...false };
|
||||
let spreadFunc = { ...(function () { }) };
|
||||
|
||||
// strings get a numeric indexer: [n: number]: string
|
||||
let spreadStr = { ...'foo' };
|
||||
|
||||
// methods are not enumerable
|
||||
|
|
|
@ -2,6 +2,7 @@ class C {
|
|||
a: number;
|
||||
c: boolean;
|
||||
}
|
||||
// index signatures are not allowed in object literals with spread types
|
||||
let c: { ...C, b: string, c?: string, [n: number]: string };
|
||||
let n: number = c.a;
|
||||
let s: string = c[12];
|
||||
|
|
Loading…
Reference in a new issue