Skip to content

Commit 519e19a

Browse files
committed
Accept new baselines
1 parent 307a9b6 commit 519e19a

File tree

4 files changed

+402
-0
lines changed

4 files changed

+402
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(31,8): error TS2339: Property 'x' does not exist on type 'Number'.
2+
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(32,9): error TS2339: Property 'x' does not exist on type 'Number'.
3+
tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(33,9): error TS2537: Type 'Number' has no matching index signature for type 'string'.
4+
5+
6+
==== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts (3 errors) ====
7+
function f1(obj: { a?: string }) {
8+
if (obj.a) {
9+
obj = {};
10+
let a1 = obj["a"]; // string | undefined
11+
let a2 = obj.a; // string | undefined
12+
}
13+
}
14+
15+
function f2(obj: [number, string] | null[]) {
16+
let a0 = obj[0]; // number | null
17+
let a1 = obj[1]; // string | null
18+
let [b0, b1] = obj;
19+
([a0, a1] = obj);
20+
if (obj[0] && obj[1]) {
21+
let c0 = obj[0]; // number
22+
let c1 = obj[1]; // string
23+
let [d0, d1] = obj;
24+
([c0, c1] = obj);
25+
}
26+
}
27+
28+
function f3(obj: { a?: number, b?: string }) {
29+
if (obj.a && obj.b) {
30+
let { a, b } = obj; // number, string
31+
({ a, b } = obj);
32+
}
33+
}
34+
35+
function f4() {
36+
let x: boolean;
37+
({ x } = 0); // Error
38+
~
39+
!!! error TS2339: Property 'x' does not exist on type 'Number'.
40+
({ ["x"]: x } = 0); // Error
41+
~~~
42+
!!! error TS2339: Property 'x' does not exist on type 'Number'.
43+
({ ["x" + ""]: x } = 0); // Errpr
44+
~~~~~~~~
45+
!!! error TS2537: Type 'Number' has no matching index signature for type 'string'.
46+
}
47+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//// [destructuringControlFlow.ts]
2+
function f1(obj: { a?: string }) {
3+
if (obj.a) {
4+
obj = {};
5+
let a1 = obj["a"]; // string | undefined
6+
let a2 = obj.a; // string | undefined
7+
}
8+
}
9+
10+
function f2(obj: [number, string] | null[]) {
11+
let a0 = obj[0]; // number | null
12+
let a1 = obj[1]; // string | null
13+
let [b0, b1] = obj;
14+
([a0, a1] = obj);
15+
if (obj[0] && obj[1]) {
16+
let c0 = obj[0]; // number
17+
let c1 = obj[1]; // string
18+
let [d0, d1] = obj;
19+
([c0, c1] = obj);
20+
}
21+
}
22+
23+
function f3(obj: { a?: number, b?: string }) {
24+
if (obj.a && obj.b) {
25+
let { a, b } = obj; // number, string
26+
({ a, b } = obj);
27+
}
28+
}
29+
30+
function f4() {
31+
let x: boolean;
32+
({ x } = 0); // Error
33+
({ ["x"]: x } = 0); // Error
34+
({ ["x" + ""]: x } = 0); // Errpr
35+
}
36+
37+
38+
//// [destructuringControlFlow.js]
39+
"use strict";
40+
function f1(obj) {
41+
if (obj.a) {
42+
obj = {};
43+
var a1 = obj["a"]; // string | undefined
44+
var a2 = obj.a; // string | undefined
45+
}
46+
}
47+
function f2(obj) {
48+
var a0 = obj[0]; // number | null
49+
var a1 = obj[1]; // string | null
50+
var b0 = obj[0], b1 = obj[1];
51+
(a0 = obj[0], a1 = obj[1]);
52+
if (obj[0] && obj[1]) {
53+
var c0 = obj[0]; // number
54+
var c1 = obj[1]; // string
55+
var d0 = obj[0], d1 = obj[1];
56+
(c0 = obj[0], c1 = obj[1]);
57+
}
58+
}
59+
function f3(obj) {
60+
if (obj.a && obj.b) {
61+
var a = obj.a, b = obj.b; // number, string
62+
(a = obj.a, b = obj.b);
63+
}
64+
}
65+
function f4() {
66+
var _a;
67+
var x;
68+
(x = 0..x); // Error
69+
(x = 0["x"]); // Error
70+
(_a = "x" + "", x = 0[_a]); // Errpr
71+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
=== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts ===
2+
function f1(obj: { a?: string }) {
3+
>f1 : Symbol(f1, Decl(destructuringControlFlow.ts, 0, 0))
4+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12))
5+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
6+
7+
if (obj.a) {
8+
>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
9+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12))
10+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
11+
12+
obj = {};
13+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12))
14+
15+
let a1 = obj["a"]; // string | undefined
16+
>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 3, 11))
17+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12))
18+
>"a" : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
19+
20+
let a2 = obj.a; // string | undefined
21+
>a2 : Symbol(a2, Decl(destructuringControlFlow.ts, 4, 11))
22+
>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
23+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 0, 12))
24+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 0, 18))
25+
}
26+
}
27+
28+
function f2(obj: [number, string] | null[]) {
29+
>f2 : Symbol(f2, Decl(destructuringControlFlow.ts, 6, 1))
30+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
31+
32+
let a0 = obj[0]; // number | null
33+
>a0 : Symbol(a0, Decl(destructuringControlFlow.ts, 9, 7))
34+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
35+
>0 : Symbol(0)
36+
37+
let a1 = obj[1]; // string | null
38+
>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 10, 7))
39+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
40+
>1 : Symbol(1)
41+
42+
let [b0, b1] = obj;
43+
>b0 : Symbol(b0, Decl(destructuringControlFlow.ts, 11, 9))
44+
>b1 : Symbol(b1, Decl(destructuringControlFlow.ts, 11, 12))
45+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
46+
47+
([a0, a1] = obj);
48+
>a0 : Symbol(a0, Decl(destructuringControlFlow.ts, 9, 7))
49+
>a1 : Symbol(a1, Decl(destructuringControlFlow.ts, 10, 7))
50+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
51+
52+
if (obj[0] && obj[1]) {
53+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
54+
>0 : Symbol(0)
55+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
56+
>1 : Symbol(1)
57+
58+
let c0 = obj[0]; // number
59+
>c0 : Symbol(c0, Decl(destructuringControlFlow.ts, 14, 11))
60+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
61+
>0 : Symbol(0)
62+
63+
let c1 = obj[1]; // string
64+
>c1 : Symbol(c1, Decl(destructuringControlFlow.ts, 15, 11))
65+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
66+
>1 : Symbol(1)
67+
68+
let [d0, d1] = obj;
69+
>d0 : Symbol(d0, Decl(destructuringControlFlow.ts, 16, 13))
70+
>d1 : Symbol(d1, Decl(destructuringControlFlow.ts, 16, 16))
71+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
72+
73+
([c0, c1] = obj);
74+
>c0 : Symbol(c0, Decl(destructuringControlFlow.ts, 14, 11))
75+
>c1 : Symbol(c1, Decl(destructuringControlFlow.ts, 15, 11))
76+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 8, 12))
77+
}
78+
}
79+
80+
function f3(obj: { a?: number, b?: string }) {
81+
>f3 : Symbol(f3, Decl(destructuringControlFlow.ts, 19, 1))
82+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12))
83+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18))
84+
>b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30))
85+
86+
if (obj.a && obj.b) {
87+
>obj.a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18))
88+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12))
89+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 21, 18))
90+
>obj.b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30))
91+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12))
92+
>b : Symbol(b, Decl(destructuringControlFlow.ts, 21, 30))
93+
94+
let { a, b } = obj; // number, string
95+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 23, 13))
96+
>b : Symbol(b, Decl(destructuringControlFlow.ts, 23, 16))
97+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12))
98+
99+
({ a, b } = obj);
100+
>a : Symbol(a, Decl(destructuringControlFlow.ts, 24, 10))
101+
>b : Symbol(b, Decl(destructuringControlFlow.ts, 24, 13))
102+
>obj : Symbol(obj, Decl(destructuringControlFlow.ts, 21, 12))
103+
}
104+
}
105+
106+
function f4() {
107+
>f4 : Symbol(f4, Decl(destructuringControlFlow.ts, 26, 1))
108+
109+
let x: boolean;
110+
>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7))
111+
112+
({ x } = 0); // Error
113+
>x : Symbol(x, Decl(destructuringControlFlow.ts, 30, 6))
114+
115+
({ ["x"]: x } = 0); // Error
116+
>["x"] : Symbol(["x"], Decl(destructuringControlFlow.ts, 31, 6))
117+
>"x" : Symbol(["x"], Decl(destructuringControlFlow.ts, 31, 6))
118+
>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7))
119+
120+
({ ["x" + ""]: x } = 0); // Errpr
121+
>["x" + ""] : Symbol(["x" + ""], Decl(destructuringControlFlow.ts, 32, 6))
122+
>x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7))
123+
}
124+

0 commit comments

Comments
 (0)