-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve typing for Generators and Async Generators
- Loading branch information
Showing
266 changed files
with
2,949 additions
and
1,556 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/// <reference lib="es2018.asynciterable" /> | ||
|
||
interface AsyncGenerator<TYield = unknown, TReturn = void, TNext = unknown> { | ||
next(value?: TNext): Promise<IteratorResult<TYield, TReturn>>; | ||
return(value: TReturn): Promise<IteratorResult<TYield, TReturn>>; | ||
throw(e: unknown): Promise<IteratorResult<TYield, TReturn>>; | ||
[Symbol.asyncIterator](): AsyncGenerator<TYield, TReturn, TNext>; | ||
} | ||
|
||
interface AsyncGeneratorFunction { | ||
/** | ||
* Creates a new AsyncGenerator object. | ||
* @param args A list of arguments the function accepts. | ||
*/ | ||
new (...args: any[]): AsyncGenerator; | ||
/** | ||
* Creates a new AsyncGenerator object. | ||
* @param args A list of arguments the function accepts. | ||
*/ | ||
(...args: any[]): AsyncGenerator; | ||
/** | ||
* The length of the arguments. | ||
*/ | ||
readonly length: number; | ||
/** | ||
* Returns the name of the function. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* A reference to the prototype. | ||
*/ | ||
readonly prototype: AsyncGenerator; | ||
} | ||
|
||
interface AsyncGeneratorFunctionConstructor { | ||
/** | ||
* Creates a new AsyncGenerator function. | ||
* @param args A list of arguments the function accepts. | ||
*/ | ||
new (...args: string[]): AsyncGeneratorFunction; | ||
/** | ||
* Creates a new AsyncGenerator function. | ||
* @param args A list of arguments the function accepts. | ||
*/ | ||
(...args: string[]): AsyncGeneratorFunction; | ||
/** | ||
* The length of the arguments. | ||
*/ | ||
readonly length: number; | ||
/** | ||
* Returns the name of the function. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* A reference to the prototype. | ||
*/ | ||
readonly prototype: AsyncGeneratorFunction; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts === | ||
function * yield() { | ||
>yield : () => IterableIterator<any> | ||
>yield : () => Generator<never, void, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts === | ||
function * foo() { | ||
>foo : () => IterableIterator<any> | ||
>foo : () => Generator<never, void, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts === | ||
function*foo(a = yield) { | ||
>foo : (a?: any) => IterableIterator<any> | ||
>foo : (a?: any) => Generator<never, void, unknown> | ||
>a : any | ||
>yield : any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts === | ||
function * foo() { | ||
>foo : () => IterableIterator<any> | ||
>foo : () => Generator<any, void, unknown> | ||
|
||
var v = { [yield]: foo } | ||
>v : { [x: number]: () => IterableIterator<any>; } | ||
>{ [yield]: foo } : { [x: number]: () => IterableIterator<any>; } | ||
>[yield] : () => IterableIterator<any> | ||
>v : { [x: number]: () => Generator<any, void, unknown>; } | ||
>{ [yield]: foo } : { [x: number]: () => Generator<any, void, unknown>; } | ||
>[yield] : () => Generator<any, void, unknown> | ||
>yield : any | ||
>foo : () => IterableIterator<any> | ||
>foo : () => Generator<any, void, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
=== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts === | ||
var v = function * () { } | ||
>v : () => IterableIterator<any> | ||
>function * () { } : () => IterableIterator<any> | ||
>v : () => Generator<never, void, unknown> | ||
>function * () { } : () => Generator<never, void, unknown> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts === | ||
var v = function * foo() { } | ||
>v : () => IterableIterator<any> | ||
>function * foo() { } : () => IterableIterator<any> | ||
>foo : () => IterableIterator<any> | ||
>v : () => Generator<never, void, unknown> | ||
>function * foo() { } : () => Generator<never, void, unknown> | ||
>foo : () => Generator<never, void, unknown> | ||
|
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/FunctionPropertyAssignments1_es6.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts === | ||
var v = { *foo() { } } | ||
>v : { foo(): IterableIterator<any>; } | ||
>{ *foo() { } } : { foo(): IterableIterator<any>; } | ||
>foo : () => IterableIterator<any> | ||
>v : { foo(): Generator<never, void, unknown>; } | ||
>{ *foo() { } } : { foo(): Generator<never, void, unknown>; } | ||
>foo : () => Generator<never, void, unknown> | ||
|
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/FunctionPropertyAssignments2_es6.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts === | ||
var v = { *() { } } | ||
>v : { (Missing)(): IterableIterator<any>; } | ||
>{ *() { } } : { (Missing)(): IterableIterator<any>; } | ||
> : () => IterableIterator<any> | ||
>v : { (Missing)(): Generator<never, void, unknown>; } | ||
>{ *() { } } : { (Missing)(): Generator<never, void, unknown>; } | ||
> : () => Generator<never, void, unknown> | ||
|
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/FunctionPropertyAssignments3_es6.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts === | ||
var v = { *{ } } | ||
>v : { (Missing)(): IterableIterator<any>; } | ||
>{ *{ } } : { (Missing)(): IterableIterator<any>; } | ||
> : () => IterableIterator<any> | ||
>v : { (Missing)(): Generator<never, void, unknown>; } | ||
>{ *{ } } : { (Missing)(): Generator<never, void, unknown>; } | ||
> : () => Generator<never, void, unknown> | ||
|
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/FunctionPropertyAssignments5_es6.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts === | ||
var v = { *[foo()]() { } } | ||
>v : { [x: number]: () => IterableIterator<any>; } | ||
>{ *[foo()]() { } } : { [x: number]: () => IterableIterator<any>; } | ||
>[foo()] : () => IterableIterator<any> | ||
>v : { [x: number]: () => Generator<never, void, unknown>; } | ||
>{ *[foo()]() { } } : { [x: number]: () => Generator<never, void, unknown>; } | ||
>[foo()] : () => Generator<never, void, unknown> | ||
>foo() : any | ||
>foo : any | ||
|
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/FunctionPropertyAssignments6_es6.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts === | ||
var v = { *<T>() { } } | ||
>v : { (Missing)<T>(): IterableIterator<any>; } | ||
>{ *<T>() { } } : { (Missing)<T>(): IterableIterator<any>; } | ||
> : <T>() => IterableIterator<any> | ||
>v : { (Missing)<T>(): Generator<never, void, unknown>; } | ||
>{ *<T>() { } } : { (Missing)<T>(): Generator<never, void, unknown>; } | ||
> : <T>() => Generator<never, void, unknown> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ class C { | |
>C : C | ||
|
||
*foo() { } | ||
>foo : () => IterableIterator<any> | ||
>foo : () => Generator<never, void, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ class C { | |
>C : C | ||
|
||
*() { } | ||
> : () => IterableIterator<any> | ||
> : () => Generator<never, void, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.