fix(isolated-declarations): correctly emit string property keys for non-identifiable name#11329
Conversation
…on-identifiable name
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
There was a problem hiding this comment.
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 Instrumentation Performance ReportMerging #11329 will not alter performanceComparing Summary
Benchmarks breakdown
|
|
Can you pick some tests from #11338? |
isolatedDeclarationfor object keys that require quotes #11318