Skip to content

fix(parser): correctly parse decorators of property declaration#11370

Merged
Dunqing merged 4 commits intooxc-project:mainfrom
magic-akari:fix/issue-11367
May 29, 2025
Merged

fix(parser): correctly parse decorators of property declaration#11370
Dunqing merged 4 commits intooxc-project:mainfrom
magic-akari:fix/issue-11367

Conversation

@graphite-app
Copy link
Contributor

graphite-app bot commented May 29, 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.

@github-actions github-actions bot added A-parser Area - Parser A-isolated-declarations Isolated Declarations C-bug Category - Bug labels May 29, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 29, 2025

CodSpeed Instrumentation Performance Report

Merging #11370 will not alter performance

Comparing magic-akari:fix/issue-11367 (34e2dfa) with main (e93caa4)

Summary

✅ 38 untouched benchmarks

@magic-akari magic-akari marked this pull request as ready for review May 29, 2025 10:08
Copilot AI review requested due to automatic review settings May 29, 2025 10:08
@magic-akari magic-akari requested a review from Dunqing as a code owner May 29, 2025 10:08
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 fixes the parser logic for processing property decorators by reordering the parsing of type annotations and consuming decorators.

  • Re-orders the parsing flow to first consume decorators and then parse type annotations.
  • Updates the snapshot and fixture files for TS property decorators.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_parser/src/js/class.rs Reordered the processing of type annotations and decorators to correctly parse decorators on property declarations.
crates/oxc_isolated_declarations/tests/snapshots/class-decorator.snap Added expected snapshot output for class decorators.
crates/oxc_isolated_declarations/tests/fixtures/class-decorator.ts Added test fixture demonstrating decorator usage on properties.

@Dunqing
Copy link
Member

Dunqing commented May 29, 2025

Can you add these tests to https://github.com/oxc-project/oxc/blob/d78c04e06ab1d92f3ecd67acd5a5f58f5af76d32/crates/oxc_codegen/tests/integration/unit.rs as well? This way we can know the bug comes from the parser or the isolatedDeclaration transformation if it breaks in the future.

@github-actions github-actions bot added the A-codegen Area - Code Generation label May 29, 2025
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for taking the time on this!

@Dunqing Dunqing merged commit daaa8f5 into oxc-project:main May 29, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation A-isolated-declarations Isolated Declarations A-parser Area - Parser C-bug Category - Bug

Projects

None yet

3 participants