Skip to content

Comments

refactor(transformer/typescript): use exhaustive match#15711

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-15-refactor_transformer_typescript_use_exhaustive_match
Nov 17, 2025
Merged

refactor(transformer/typescript): use exhaustive match#15711
graphite-app[bot] merged 1 commit intomainfrom
11-15-refactor_transformer_typescript_use_exhaustive_match

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 15, 2025

Pure refactor. Use an exhaustive match, so get a compilation error rather than misbehavior if we add a Declaration variant (I hit this problem in #15712).

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Nov 15, 2025
Copy link
Member Author

overlookmotel commented Nov 15, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review November 15, 2025 11:36
Copilot AI review requested due to automatic review settings November 15, 2025 11:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors a match statement on the Declaration enum to use exhaustive pattern matching instead of a catch-all pattern. This ensures compile-time errors if new Declaration variants are added in the future, preventing potential runtime misbehavior.

Key Changes:

  • Refactored FunctionDeclaration match arm from guard pattern to nested if statement
  • Replaced catch-all _ => {} with explicit TSTypeAliasDeclaration | TSInterfaceDeclaration pattern
  • All 8 Declaration variants now explicitly matched

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 15, 2025

CodSpeed Performance Report

Merging #15711 will not alter performance

Comparing 11-15-refactor_transformer_typescript_use_exhaustive_match (ff4b9c8) with main (56e7e44)1

Summary

✅ 33 untouched
⏩ 4 skipped2

Footnotes

  1. No successful run was found on main (50f1ec0) during the generation of this report, so 56e7e44 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Nov 17, 2025
Copy link
Member

Dunqing commented Nov 17, 2025

Merge activity

Pure refactor. Use an exhaustive match, so get a compilation error rather than misbehavior if we add a `Declaration` variant (I hit this problem in #15712).
@graphite-app graphite-app bot force-pushed the 11-15-refactor_transformer_typescript_use_exhaustive_match branch from ff4b9c8 to c400e5e Compare November 17, 2025 07:47
@graphite-app graphite-app bot merged commit c400e5e into main Nov 17, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 11-15-refactor_transformer_typescript_use_exhaustive_match branch November 17, 2025 07:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 17, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…5711)

Pure refactor. Use an exhaustive match, so get a compilation error rather than misbehavior if we add a `Declaration` variant (I hit this problem in oxc-project#15712).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants