-
Notifications
You must be signed in to change notification settings - Fork 13.3k
T[] | { t: 'a' } & { t: 'b' } is not iterable (TS2488)Β #62462
Copy link
Copy link
Closed
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionFix AvailableA PR has been opened for this issueA PR has been opened for this issuePossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Metadata
Metadata
Assignees
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionFix AvailableA PR has been opened for this issueA PR has been opened for this issuePossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
π Search Terms
TS2488
π Version & Regression Information
tscβ― Playground Link
https://www.typescriptlang.org/play/?ts=3.9.7#code/CYUwxgNghgTiAEA3W8AeAueA7ArgWwCMQYBtAXXgB94BveAF0wHIon4BfeAMloeYLbsAUBBD14JEKLwUAvGiA
π» Code
π Actual behavior
The array destructure fails with this error:
π Expected behavior
No error should be present.
Since an object cannot have a field
tthat holds both'a'and'b',{ t: 'a' } & { t: 'b' }reduces tonever. Andnumber[] | neverdecays tonumber[], which is iterable by definition.Additional information about the issue
No response