Skip to content

Commit 8b4db98

Browse files
committed
Add test case for nested object spread / methods
See microsoft#16765.
1 parent 903d137 commit 8b4db98

4 files changed

+89
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [objectSpreadWithinMethodWithinObjectWithSpread.ts]
2+
const obj = {};
3+
const a = {
4+
...obj,
5+
prop() {
6+
return {
7+
...obj,
8+
metadata: 213
9+
};
10+
}
11+
};
12+
13+
14+
//// [objectSpreadWithinMethodWithinObjectWithSpread.js]
15+
var __assign = (this && this.__assign) || Object.assign || function(t) {
16+
for (var s, i = 1, n = arguments.length; i < n; i++) {
17+
s = arguments[i];
18+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19+
t[p] = s[p];
20+
}
21+
return t;
22+
};
23+
var obj = {};
24+
var a = __assign({}, obj, { prop: function () {
25+
return __assign({}, obj, { metadata: 213 });
26+
} });
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
2+
const obj = {};
3+
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
4+
5+
const a = {
6+
>a : Symbol(a, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 1, 5))
7+
8+
...obj,
9+
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
10+
11+
prop() {
12+
>prop : Symbol(prop, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 2, 11))
13+
14+
return {
15+
...obj,
16+
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
17+
18+
metadata: 213
19+
>metadata : Symbol(metadata, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 5, 19))
20+
21+
};
22+
}
23+
};
24+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
2+
const obj = {};
3+
>obj : {}
4+
>{} : {}
5+
6+
const a = {
7+
>a : { prop(): { metadata: number; }; }
8+
>{ ...obj, prop() { return { ...obj, metadata: 213 }; }} : { prop(): { metadata: number; }; }
9+
10+
...obj,
11+
>obj : {}
12+
13+
prop() {
14+
>prop : () => { metadata: number; }
15+
16+
return {
17+
>{ ...obj, metadata: 213 } : { metadata: number; }
18+
19+
...obj,
20+
>obj : {}
21+
22+
metadata: 213
23+
>metadata : number
24+
>213 : 213
25+
26+
};
27+
}
28+
};
29+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const obj = {};
2+
const a = {
3+
...obj,
4+
prop() {
5+
return {
6+
...obj,
7+
metadata: 213
8+
};
9+
}
10+
};

0 commit comments

Comments
 (0)