Skip to content
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

Fixes #58268 - Improve Tuple Type Handling and Address Circular References #60584

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RyanMyrvold
Copy link

@RyanMyrvold RyanMyrvold commented Nov 25, 2024

Fixes #58268

What was fixed:
The compiler was failing with stack overflows or complexity errors when processing certain tuple types, particularly deeply nested or concatenated tuples.

Solution:
We refactored how tuple element types are extracted to handle recursive and complex structures more robustly. A new function, getTupleElementTypes, was added to:

  • Safely resolve tuple elements, using resolvedTypeArguments when available.
  • Prevent infinite recursion with a circular reference guard.
  • Differentiate between tuple types and references without unsafe type assertions.

This ensures tuple-related operations no longer result in stack overflows and handle complexity gracefully.

…iled logging.

- Corrected the handling of tuple types in `getTupleElementTypes`:
  - Implemented proper checks for resolved type arguments and element flags.
  - Ensured accurate identification of tuple types using `isTupleType`.
- Added a guard against circular references by using a `Set` to track seen types.
- Enhanced debugging by adding detailed console logs:
  - Logs the type being analyzed.
  - Warns when a circular reference is detected.
  - Logs when a tuple type is detected and when resolved type arguments are found.
  - Indicates when a type is not a tuple.
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 25, 2024
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

TS2590: Expression produces a union type that is too complex to represent, with simple file using Tuples
2 participants