Skip to content

Commit 9ad0832

Browse files
committed
Fix #8357: Remove optionality for the definition of IteratorResult
1 parent f28d535 commit 9ad0832

5 files changed

+97
-1
lines changed

src/lib/es2015.iterable.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
interface IteratorResult<T> {
44
done: boolean;
5-
value?: T;
5+
value: T;
66
}
77

88
interface Iterator<T> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [iteratorsAndStrictNullChecks.ts]
2+
3+
// for..of
4+
for (const x of ["a", "b"]) {
5+
x.substring;
6+
}
7+
8+
// Spread
9+
const xs = [1, 2, 3];
10+
const ys = [4, 5];
11+
xs.push(...ys);
12+
13+
14+
//// [iteratorsAndStrictNullChecks.js]
15+
// for..of
16+
for (const x of ["a", "b"]) {
17+
x.substring;
18+
}
19+
// Spread
20+
const xs = [1, 2, 3];
21+
const ys = [4, 5];
22+
xs.push(...ys);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/compiler/iteratorsAndStrictNullChecks.ts ===
2+
3+
// for..of
4+
for (const x of ["a", "b"]) {
5+
>x : Symbol(x, Decl(iteratorsAndStrictNullChecks.ts, 2, 10))
6+
7+
x.substring;
8+
>x.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
9+
>x : Symbol(x, Decl(iteratorsAndStrictNullChecks.ts, 2, 10))
10+
>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --))
11+
}
12+
13+
// Spread
14+
const xs = [1, 2, 3];
15+
>xs : Symbol(xs, Decl(iteratorsAndStrictNullChecks.ts, 7, 5))
16+
17+
const ys = [4, 5];
18+
>ys : Symbol(ys, Decl(iteratorsAndStrictNullChecks.ts, 8, 5))
19+
20+
xs.push(...ys);
21+
>xs.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
22+
>xs : Symbol(xs, Decl(iteratorsAndStrictNullChecks.ts, 7, 5))
23+
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
24+
>ys : Symbol(ys, Decl(iteratorsAndStrictNullChecks.ts, 8, 5))
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== tests/cases/compiler/iteratorsAndStrictNullChecks.ts ===
2+
3+
// for..of
4+
for (const x of ["a", "b"]) {
5+
>x : string
6+
>["a", "b"] : string[]
7+
>"a" : string
8+
>"b" : string
9+
10+
x.substring;
11+
>x.substring : (start: number, end?: number | undefined) => string
12+
>x : string
13+
>substring : (start: number, end?: number | undefined) => string
14+
}
15+
16+
// Spread
17+
const xs = [1, 2, 3];
18+
>xs : number[]
19+
>[1, 2, 3] : number[]
20+
>1 : number
21+
>2 : number
22+
>3 : number
23+
24+
const ys = [4, 5];
25+
>ys : number[]
26+
>[4, 5] : number[]
27+
>4 : number
28+
>5 : number
29+
30+
xs.push(...ys);
31+
>xs.push(...ys) : number
32+
>xs.push : (...items: number[]) => number
33+
>xs : number[]
34+
>push : (...items: number[]) => number
35+
>...ys : number
36+
>ys : number[]
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @target : ES6
2+
// @strictNullChecks: true
3+
4+
// for..of
5+
for (const x of ["a", "b"]) {
6+
x.substring;
7+
}
8+
9+
// Spread
10+
const xs = [1, 2, 3];
11+
const ys = [4, 5];
12+
xs.push(...ys);

0 commit comments

Comments
 (0)