Skip to content

fix(isolated-declarations): correctly emit string property keys for non-identifiable name#11329

Merged
Dunqing merged 10 commits intooxc-project:mainfrom
magic-akari:fix/issue-11318
May 28, 2025
Merged

fix(isolated-declarations): correctly emit string property keys for non-identifiable name#11329
Dunqing merged 10 commits intooxc-project:mainfrom
magic-akari:fix/issue-11318

Conversation

@magic-akari
Copy link
Contributor

@magic-akari magic-akari commented May 27, 2025

Copilot AI review requested due to automatic review settings May 27, 2025 17:55
@magic-akari magic-akari requested a review from Dunqing as a code owner May 27, 2025 17:55
@graphite-app
Copy link
Contributor

graphite-app bot commented May 27, 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-isolated-declarations Isolated Declarations C-bug Category - Bug labels May 27, 2025
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 addresses issue #11318 by fixing the emission of string property keys for non-identifiable names in isolated declarations.

  • Updates snapshot tests and fixture files to include examples of string property keys that are not valid identifiers.
  • Conditions in the emitter now check if a string literal or template literal represents a valid identifier before emitting it as a static identifier.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_isolated_declarations/tests/snapshots/object.snap Updated snapshot to reflect correct string property keys and new declarations (type family, theme, X).
crates/oxc_isolated_declarations/tests/fixtures/object.ts Updated fixture test with new syntax for type family, theme, and an object with reserved words as keys.
crates/oxc_isolated_declarations/src/types.rs Refactored property key emission logic to conditionally emit identifiers only when the literal is a valid identifier.
Comments suppressed due to low confidence (1)

crates/oxc_isolated_declarations/src/types.rs:82

  • [nitpick] Consider adding a comment to clarify that only the first quasi of a template literal is used for identifier validation, in case multi-segment templates are supported in the future.
PropertyKey::TemplateLiteral(literal) if is_identifier_name(&literal.quasis[0].value.raw) => {

@codspeed-hq
Copy link

codspeed-hq bot commented May 27, 2025

CodSpeed Instrumentation Performance Report

Merging #11329 will not alter performance

Comparing magic-akari:fix/issue-11318 (0102309) with main (3249ab6)

Summary

✅ 34 untouched benchmarks
⁉️ 4 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
⁉️ semantic[RadixUIAdoptionSection.jsx] 72 µs N/A N/A
⁉️ semantic[binder.ts] 3.9 ms N/A N/A
⁉️ semantic[cal.com.tsx] 25.4 ms N/A N/A
⁉️ semantic[react.development.js] 1.5 ms N/A N/A

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.

Thanks! Overall are good!

@Dunqing
Copy link
Member

Dunqing commented May 28, 2025

Can you pick some tests from #11338?

@Dunqing Dunqing merged commit 3249ab6 into oxc-project:main May 28, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-isolated-declarations Isolated Declarations C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escape with Quotes for isolatedDeclarations oxc-transform: invalid syntax output with isolatedDeclaration for object keys that require quotes

4 participants