Skip to content

Commit b5104cb

Browse files
committed
Accepting new baselines
1 parent 538e22a commit b5104cb

File tree

2 files changed

+147
-5
lines changed

2 files changed

+147
-5
lines changed

tests/baselines/reference/controlFlowIterationErrors.errors.txt

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(11,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
1+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(12,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
22
Type 'number' is not assignable to type 'string'.
3-
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(22,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
3+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(23,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
44
Type 'number' is not assignable to type 'string'.
5-
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(34,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
5+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(35,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
66
Type 'string' is not assignable to type 'number'.
7-
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(45,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
7+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(46,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
88
Type 'string' is not assignable to type 'number'.
9+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
10+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
11+
Type 'boolean' is not assignable to type 'string | number'.
12+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
13+
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
14+
Type 'boolean' is not assignable to type 'string | number'.
915

1016

11-
==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (4 errors) ====
17+
==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (8 errors) ====
18+
1219
let cond: boolean;
1320

1421
function len(s: string) {
@@ -69,4 +76,57 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(45,17): error
6976
}
7077
x;
7178
}
79+
80+
function asNumber(x: string | number): number {
81+
return +x;
82+
}
83+
84+
function h1() {
85+
let x: string | number | boolean;
86+
x = "0";
87+
while (cond) {
88+
x = +x + 1;
89+
x;
90+
}
91+
}
92+
93+
function h2() {
94+
let x: string | number | boolean;
95+
x = "0";
96+
while (cond) {
97+
x = asNumber(x) + 1;
98+
x;
99+
}
100+
}
101+
102+
function h3() {
103+
let x: string | number | boolean;
104+
x = "0";
105+
while (cond) {
106+
let y = asNumber(x);
107+
~
108+
!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
109+
~
110+
!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
111+
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
112+
x = y + 1;
113+
x;
114+
}
115+
}
116+
117+
function h4() {
118+
let x: string | number | boolean;
119+
x = "0";
120+
while (cond) {
121+
x;
122+
let y = asNumber(x);
123+
~
124+
!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
125+
~
126+
!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'.
127+
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
128+
x = y + 1;
129+
x;
130+
}
131+
}
72132

tests/baselines/reference/controlFlowIterationErrors.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [controlFlowIterationErrors.ts]
2+
23
let cond: boolean;
34

45
function len(s: string) {
@@ -47,6 +48,49 @@ function g2() {
4748
}
4849
x;
4950
}
51+
52+
function asNumber(x: string | number): number {
53+
return +x;
54+
}
55+
56+
function h1() {
57+
let x: string | number | boolean;
58+
x = "0";
59+
while (cond) {
60+
x = +x + 1;
61+
x;
62+
}
63+
}
64+
65+
function h2() {
66+
let x: string | number | boolean;
67+
x = "0";
68+
while (cond) {
69+
x = asNumber(x) + 1;
70+
x;
71+
}
72+
}
73+
74+
function h3() {
75+
let x: string | number | boolean;
76+
x = "0";
77+
while (cond) {
78+
let y = asNumber(x);
79+
x = y + 1;
80+
x;
81+
}
82+
}
83+
84+
function h4() {
85+
let x: string | number | boolean;
86+
x = "0";
87+
while (cond) {
88+
x;
89+
let y = asNumber(x);
90+
x = y + 1;
91+
x;
92+
}
93+
}
5094

5195

5296
//// [controlFlowIterationErrors.js]
@@ -90,3 +134,41 @@ function g2() {
90134
}
91135
x;
92136
}
137+
function asNumber(x) {
138+
return +x;
139+
}
140+
function h1() {
141+
var x;
142+
x = "0";
143+
while (cond) {
144+
x = +x + 1;
145+
x;
146+
}
147+
}
148+
function h2() {
149+
var x;
150+
x = "0";
151+
while (cond) {
152+
x = asNumber(x) + 1;
153+
x;
154+
}
155+
}
156+
function h3() {
157+
var x;
158+
x = "0";
159+
while (cond) {
160+
var y = asNumber(x);
161+
x = y + 1;
162+
x;
163+
}
164+
}
165+
function h4() {
166+
var x;
167+
x = "0";
168+
while (cond) {
169+
x;
170+
var y = asNumber(x);
171+
x = y + 1;
172+
x;
173+
}
174+
}

0 commit comments

Comments
 (0)