-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
fix(38388) Add support for this
parameters in iterationTypes and fix caching issues
#41451
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7815ff0
Make implicit Symbol.iterator calls use resolveCall
Validark 7e44daa
Make resolveCall node argument possibly undefined
Validark a3a0016
Retain errors for cached iterationTypes
Validark 75eb677
Fix iterationTypes caching, add tests
Validark 1ede677
Add explanation to resolveCall
Validark 201b55f
Finishing touches, add arityError tests
Validark 64b97af
Finish up iterator redux
Validark cb6de59
Optimize cache-ing a little more for iterationTypes
Validark ce784b8
Update errorsInGenericTypeReference
Validark af8596d
Update errorsInGenericTypeReference whitespace....?
Validark 9eac547
Fix typo
Validark 7f54f67
Merge 'origin/master' into iter-fix
Validark 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
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
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/cachedIterableTypesShouldAlwaysError.errors.txt
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,22 @@ | ||
tests/cases/compiler/cachedIterableTypesShouldAlwaysError.ts(5,18): error TS2488: Type '{ x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
tests/cases/compiler/cachedIterableTypesShouldAlwaysError.ts(9,18): error TS2488: Type '{ x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
|
||
|
||
==== tests/cases/compiler/cachedIterableTypesShouldAlwaysError.ts (2 errors) ==== | ||
function foo(obj: | ||
{ x: "x", [Symbol.iterator](): Generator<{ b: false }> } | | ||
{ y: "y" } | ||
) { | ||
for (const k of obj) { // should error | ||
~~~ | ||
!!! error TS2488: Type '{ x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
void k; | ||
} | ||
|
||
for (const k of obj) { // should error | ||
~~~ | ||
!!! error TS2488: Type '{ x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; }' must have a '[Symbol.iterator]()' method that returns an iterator. | ||
void k; | ||
} | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/cachedIterableTypesShouldAlwaysError.js
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,24 @@ | ||
//// [cachedIterableTypesShouldAlwaysError.ts] | ||
function foo(obj: | ||
{ x: "x", [Symbol.iterator](): Generator<{ b: false }> } | | ||
{ y: "y" } | ||
) { | ||
for (const k of obj) { // should error | ||
void k; | ||
} | ||
|
||
for (const k of obj) { // should error | ||
void k; | ||
} | ||
} | ||
|
||
|
||
//// [cachedIterableTypesShouldAlwaysError.js] | ||
function foo(obj) { | ||
for (const k of obj) { // should error | ||
void k; | ||
} | ||
for (const k of obj) { // should error | ||
void k; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/cachedIterableTypesShouldAlwaysError.symbols
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,35 @@ | ||
=== tests/cases/compiler/cachedIterableTypesShouldAlwaysError.ts === | ||
function foo(obj: | ||
>foo : Symbol(foo, Decl(cachedIterableTypesShouldAlwaysError.ts, 0, 0)) | ||
>obj : Symbol(obj, Decl(cachedIterableTypesShouldAlwaysError.ts, 0, 13)) | ||
|
||
{ x: "x", [Symbol.iterator](): Generator<{ b: false }> } | | ||
>x : Symbol(x, Decl(cachedIterableTypesShouldAlwaysError.ts, 1, 5)) | ||
>[Symbol.iterator] : Symbol([Symbol.iterator], Decl(cachedIterableTypesShouldAlwaysError.ts, 1, 13)) | ||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) | ||
>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) | ||
>b : Symbol(b, Decl(cachedIterableTypesShouldAlwaysError.ts, 1, 46)) | ||
|
||
{ y: "y" } | ||
>y : Symbol(y, Decl(cachedIterableTypesShouldAlwaysError.ts, 2, 5)) | ||
|
||
) { | ||
for (const k of obj) { // should error | ||
>k : Symbol(k, Decl(cachedIterableTypesShouldAlwaysError.ts, 4, 11)) | ||
>obj : Symbol(obj, Decl(cachedIterableTypesShouldAlwaysError.ts, 0, 13)) | ||
|
||
void k; | ||
>k : Symbol(k, Decl(cachedIterableTypesShouldAlwaysError.ts, 4, 11)) | ||
} | ||
|
||
for (const k of obj) { // should error | ||
>k : Symbol(k, Decl(cachedIterableTypesShouldAlwaysError.ts, 8, 11)) | ||
>obj : Symbol(obj, Decl(cachedIterableTypesShouldAlwaysError.ts, 0, 13)) | ||
|
||
void k; | ||
>k : Symbol(k, Decl(cachedIterableTypesShouldAlwaysError.ts, 8, 11)) | ||
} | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/cachedIterableTypesShouldAlwaysError.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/compiler/cachedIterableTypesShouldAlwaysError.ts === | ||
function foo(obj: | ||
>foo : (obj: { x: "x"; [Symbol.iterator](): Generator<{ b: false; }>;} | { y: "y";}) => void | ||
>obj : { x: "x"; [Symbol.iterator](): Generator<{ b: false;}>; } | { y: "y"; } | ||
|
||
{ x: "x", [Symbol.iterator](): Generator<{ b: false }> } | | ||
>x : "x" | ||
>[Symbol.iterator] : () => Generator<{ b: false;}> | ||
>Symbol.iterator : symbol | ||
>Symbol : SymbolConstructor | ||
>iterator : symbol | ||
>b : false | ||
>false : false | ||
|
||
{ y: "y" } | ||
>y : "y" | ||
|
||
) { | ||
for (const k of obj) { // should error | ||
>k : any | ||
>obj : { x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; } | ||
|
||
void k; | ||
>void k : undefined | ||
>k : any | ||
} | ||
|
||
for (const k of obj) { // should error | ||
>k : any | ||
>obj : { x: "x"; [Symbol.iterator](): Generator<{ b: false; }, any, unknown>; } | { y: "y"; } | ||
|
||
void k; | ||
>void k : undefined | ||
>k : 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
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.
This is probably not good. I am still pretty sure this has nothing to do with my changes, I just wanted to update the baseline references so my tests don't fail. Perhaps another issue should be opened for this case?