Skip to content

Commit 9d2a2c9

Browse files
committed
Add tests
1 parent ddc742c commit 9d2a2c9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @strict: true
2+
3+
// Repro from #31762
4+
5+
function g1(headerNames: any) {
6+
let t = [{ hasLineBreak: false, cells: [] }];
7+
const table = [{cells: headerNames }].concat(t);
8+
}
9+
10+
function g2(headerNames: any) {
11+
let t = [{ hasLineBreak: false, cells: [] }];
12+
const table = [{cells: headerNames }]["concat"](t);
13+
}
14+
15+
// Object in property or element access is widened when target of assignment
16+
17+
function foo(options?: { a: string, b: number }) {
18+
let x1 = (options || {}).a; // Object type not widened
19+
let x2 = (options || {})["a"]; // Object type not widened
20+
(options || {}).a = 1; // Object type widened, error
21+
(options || {})["a"] = 1; // Object type widened, error
22+
}

0 commit comments

Comments
 (0)