-
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
Iterator of array intersection incorrectly typed #57002
Comments
Same cause as #41874, though slightly more egregious example. Perhaps |
Duplicate of #39693 more or less? |
So this is bogus: const iter: (() => IterableIterator<{
a: string;
}>) & (() => IterableIterator<{
b: number;
}>) The result of IterableIterator<{
a: string;
} & {
b: number;
}> I suppose it should be able to figure out from first principles without knowing a priori what an iterator has to be, |
@craigphicks I don’t understand what you’re trying to say.
I don’t know if you’re commenting on property access on an intersection type, the return type of calling an intersection of callables, and/or the intersection of two instantiations of I think something like this is the correct solution: #41451. I also think the intersection of callable types should be order-independent, but that’s likely too breaking of a change :-) |
I was talking about # 1. below. But I have expanded the analysis to include # 2. # 2 is far more important. Two approaches: 1. Treating
|
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
array intersection iterator
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240109&ssl=22&ssc=1&pln=1&pc=1#code/C4TwDgpgBAglC8UDeUCGAuKBnYAnAlgHYDmUAvgNoC6AUKJFAEILJQBGmhArgLZsS5y1OuGgBhFnABkTGjQDGAe0I40uTBMQUUGKACIAZosV6ANO0wBGAEwBmcrREMAGizEVufAbQD0PqAEAegD8ckaCABRKKsBQAB5QigZqAJTINAF+AdlBoQHRWIoANhAAdEWKxBFxpagpGVAFxWUVVTVs9WRyBbH4sYiouBQAyiB8xaV9AqjAirhUEfXhUFHKqglJUH1pSA1ZObkNTSXlldW19flrzadtpR1QWQAKuIqQuKBQAORsX1AAJooIFgoIRFLEIHF8KplFB6NAvjpMDgCCQANzkL40LpAA
💻 Code
🙁 Actual behavior
Using the iterator protocol (
Symbol.iterator
) to iterate over an intersection arrayA[] & B[]
🙂 Expected behavior
I expect the iterator returned by
Symbol.iterator
to have the same element type as thefor...of
syntax sugar, i.e.(A[number] & B[number])
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: