-
Notifications
You must be signed in to change notification settings - Fork 649
Port "Error on too many parameters for iterator method" #1059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
42 changes: 42 additions & 0 deletions
42
testdata/baselines/reference/submodule/compiler/asyncIteratorExtraParameters.errors.txt
This file contains hidden or 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,42 @@ | ||
asyncIteratorExtraParameters.ts(11,27): error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
Types of property '[Symbol.asyncIterator]' are incompatible. | ||
Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
asyncIteratorExtraParameters.ts(11,27): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
asyncIteratorExtraParameters.ts(13,12): error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
Types of property '[Symbol.asyncIterator]' are incompatible. | ||
Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
asyncIteratorExtraParameters.ts(13,12): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
|
||
|
||
==== asyncIteratorExtraParameters.ts (4 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/57130 | ||
const iter = { | ||
async *[Symbol.asyncIterator](_: number) { | ||
yield 0; | ||
} | ||
}; | ||
|
||
declare function g(...args: any): any; | ||
|
||
async function* f() { | ||
for await (const _ of iter); | ||
~~~~ | ||
!!! error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. | ||
!!! error TS2322: Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
~~~~ | ||
!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
|
||
yield* iter; | ||
~~~~ | ||
!!! error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. | ||
!!! error TS2322: Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
~~~~ | ||
!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
} | ||
|
61 changes: 37 additions & 24 deletions
61
testdata/baselines/reference/submodule/compiler/asyncIteratorExtraParameters.errors.txt.diff
This file contains hidden or 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,36 +1,49 @@ | ||
--- old.asyncIteratorExtraParameters.errors.txt | ||
+++ new.asyncIteratorExtraParameters.errors.txt | ||
@@= skipped -0, +0 lines =@@ | ||
-asyncIteratorExtraParameters.ts(11,27): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
-asyncIteratorExtraParameters.ts(13,12): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
- | ||
- | ||
+asyncIteratorExtraParameters.ts(11,27): error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
+ Types of property '[Symbol.asyncIterator]' are incompatible. | ||
+ Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
+ Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
asyncIteratorExtraParameters.ts(11,27): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
+asyncIteratorExtraParameters.ts(13,12): error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
+ Types of property '[Symbol.asyncIterator]' are incompatible. | ||
+ Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
+ Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
asyncIteratorExtraParameters.ts(13,12): error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
|
||
|
||
-==== asyncIteratorExtraParameters.ts (2 errors) ==== | ||
- // https://github.com/microsoft/TypeScript/issues/57130 | ||
- const iter = { | ||
- async *[Symbol.asyncIterator](_: number) { | ||
- yield 0; | ||
- } | ||
- }; | ||
- | ||
- declare function g(...args: any): any; | ||
- | ||
- async function* f() { | ||
- for await (const _ of iter); | ||
- ~~~~ | ||
-!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
+==== asyncIteratorExtraParameters.ts (4 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/57130 | ||
const iter = { | ||
async *[Symbol.asyncIterator](_: number) { | ||
@@= skipped -14, +22 lines =@@ | ||
async function* f() { | ||
for await (const _ of iter); | ||
~~~~ | ||
+!!! error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
+!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. | ||
+!!! error TS2322: Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
+!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
+ ~~~~ | ||
!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
-!!! related TS2322 asyncIteratorExtraParameters.ts:11:27: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
- Types of property '[Symbol.asyncIterator]' are incompatible. | ||
- Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
- Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
- | ||
- yield* iter; | ||
- ~~~~ | ||
-!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
|
||
yield* iter; | ||
~~~~ | ||
+!!! error TS2322: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
+!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. | ||
+!!! error TS2322: Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
+!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
+ ~~~~ | ||
!!! error TS2504: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. | ||
-!!! related TS2322 asyncIteratorExtraParameters.ts:13:12: Type '{ [Symbol.asyncIterator](_: number): AsyncGenerator<number, void, unknown>; }' is not assignable to type 'AsyncIterable<T, TReturn, TNext>'. | ||
- Types of property '[Symbol.asyncIterator]' are incompatible. | ||
- Type '(_: number) => AsyncGenerator<number, void, unknown>' is not assignable to type '() => AsyncIterator<T, TReturn, TNext>'. | ||
- Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
- } | ||
- | ||
+<no content> | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
testdata/baselines/reference/submodule/compiler/iteratorExtraParameters.errors.txt
This file contains hidden or 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,46 @@ | ||
iteratorExtraParameters.ts(11,21): error TS2322: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' is not assignable to type 'Iterable<T, TReturn, TNext>'. | ||
Types of property '[Symbol.iterator]' are incompatible. | ||
Type '(_: number) => Generator<number, void, unknown>' is not assignable to type '() => Iterator<T, TReturn, TNext>'. | ||
Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
iteratorExtraParameters.ts(11,21): error TS2488: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
iteratorExtraParameters.ts(13,12): error TS2322: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' is not assignable to type 'Iterable<T, TReturn, TNext>'. | ||
Types of property '[Symbol.iterator]' are incompatible. | ||
Type '(_: number) => Generator<number, void, unknown>' is not assignable to type '() => Iterator<T, TReturn, TNext>'. | ||
Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
iteratorExtraParameters.ts(13,12): error TS2488: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
|
||
|
||
==== iteratorExtraParameters.ts (4 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/57130 | ||
const iter = { | ||
*[Symbol.iterator](_: number) { | ||
yield 0; | ||
} | ||
}; | ||
|
||
declare function g(...args: any): any; | ||
|
||
function* f() { | ||
for (const _ of iter); | ||
~~~~ | ||
!!! error TS2322: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' is not assignable to type 'Iterable<T, TReturn, TNext>'. | ||
!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. | ||
!!! error TS2322: Type '(_: number) => Generator<number, void, unknown>' is not assignable to type '() => Iterator<T, TReturn, TNext>'. | ||
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
~~~~ | ||
!!! error TS2488: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
|
||
yield* iter; | ||
~~~~ | ||
!!! error TS2322: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' is not assignable to type 'Iterable<T, TReturn, TNext>'. | ||
!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. | ||
!!! error TS2322: Type '(_: number) => Generator<number, void, unknown>' is not assignable to type '() => Iterator<T, TReturn, TNext>'. | ||
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. | ||
~~~~ | ||
!!! error TS2488: Type '{ [Symbol.iterator](_: number): Generator<number, void, unknown>; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
|
||
[...iter] | ||
|
||
g(...iter); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels suspicious that this condition is flipped from the original code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just because the actual branches here are flipped, this allowed me to nearly fall through to the
IterationTypes{}
case in the case when valid signatures are missing