Skip to content

Commit 4dc9da2

Browse files
committed
Fix Iterator type in es6.d.ts
1 parent 5edb5cd commit 4dc9da2

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/lib/es6.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ interface IteratorResult<T> {
442442
}
443443

444444
interface Iterator<T> {
445-
next(): IteratorResult<T>;
446-
return?(value?: any): IteratorResult<T>;
445+
next(value?: any): IteratorResult<T>;
446+
return?(value?: T): IteratorResult<T>;
447447
throw?(e?: any): IteratorResult<T>;
448448
}
449449

tests/baselines/reference/for-of30.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty
33
Type '() => StringIterator' is not assignable to type '() => Iterator<string>'.
44
Type 'StringIterator' is not assignable to type 'Iterator<string>'.
55
Types of property 'return' are incompatible.
6-
Type 'number' is not assignable to type '(value?: any) => IteratorResult<string>'.
6+
Type 'number' is not assignable to type '(value?: string) => IteratorResult<string>'.
77

88

99
==== tests/cases/conformance/es6/for-ofStatements/for-of30.ts (1 errors) ====
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty
1414
!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator<string>'.
1515
!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator<string>'.
1616
!!! error TS2322: Types of property 'return' are incompatible.
17-
!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult<string>'.
17+
!!! error TS2322: Type 'number' is not assignable to type '(value?: string) => IteratorResult<string>'.
1818

1919
class StringIterator {
2020
next() {

tests/baselines/reference/for-of31.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty
33
Type '() => StringIterator' is not assignable to type '() => Iterator<string>'.
44
Type 'StringIterator' is not assignable to type 'Iterator<string>'.
55
Types of property 'next' are incompatible.
6-
Type '() => { value: string; }' is not assignable to type '() => IteratorResult<string>'.
6+
Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult<string>'.
77
Type '{ value: string; }' is not assignable to type 'IteratorResult<string>'.
88
Property 'done' is missing in type '{ value: string; }'.
99

@@ -16,7 +16,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty
1616
!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator<string>'.
1717
!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator<string>'.
1818
!!! error TS2322: Types of property 'next' are incompatible.
19-
!!! error TS2322: Type '() => { value: string; }' is not assignable to type '() => IteratorResult<string>'.
19+
!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult<string>'.
2020
!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult<string>'.
2121
!!! error TS2322: Property 'done' is missing in type '{ value: string; }'.
2222

tests/baselines/reference/iteratorSpreadInArray9.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322
33
Type '() => SymbolIterator' is not assignable to type '() => Iterator<symbol>'.
44
Type 'SymbolIterator' is not assignable to type 'Iterator<symbol>'.
55
Types of property 'next' are incompatible.
6-
Type '() => { value: symbol; }' is not assignable to type '() => IteratorResult<symbol>'.
6+
Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult<symbol>'.
77
Type '{ value: symbol; }' is not assignable to type 'IteratorResult<symbol>'.
88
Property 'done' is missing in type '{ value: symbol; }'.
99

@@ -16,7 +16,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322
1616
!!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator<symbol>'.
1717
!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator<symbol>'.
1818
!!! error TS2322: Types of property 'next' are incompatible.
19-
!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '() => IteratorResult<symbol>'.
19+
!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult<symbol>'.
2020
!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult<symbol>'.
2121
!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'.
2222

0 commit comments

Comments
 (0)