Repository navigation
fix(compiler): match ngtsc propDecorators member shape in setClassMetadata - #543
Merged
Merged
Conversation
…adata OXC's AOT `setClassMetadata` propDecorators diverged from ngtsc's `extractClassMetadata` (metadata.ts) in two ways: 1. Static members were included. Upstream filters `!member.isStatic` (and `accessLevel !== EcmaScriptPrivate`); OXC did not check `r#static`, so a decorated static member — or a `static x = input(0)` picked up by the synthesized initializer-API path — leaked into `propDecorators` while ngtsc omits it. 2. String-literal member keys were not marked quoted. Upstream sets `quoted: shouldQuoteName` when the member's name node is a string literal (`ts.isStringLiteralLike`), so `'x'` emits `"x":` while OXC emitted `x:`. (Illegal identifiers like 'x-y' were already quoted by the emitter's identifier check, so this is a textual divergence, not invalid output.) `build_prop_decorators_metadata_in` now skips `r#static` elements and threads a `quoted` flag from the member key (string literal or no-substitution template literal) into both `LiteralMapEntry`s, matching upstream's quote behavior exactly. The upstream duplicate-decorated-members diagnostic is not ported: it is unreachable in practice (the only same-name pair is a getter/setter, which cannot both carry decorators) and `builders.rs` has no diagnostic channel. Fixes #539
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #539.
Problem
OXC's AOT
setClassMetadatapropDecorators(build_prop_decorators_metadata_in) diverged from ngtsc'sextractClassMetadata(metadata.ts:90-115) in member shape:!member.isStaticandaccessLevel !== EcmaScriptPrivate; OXC didn't checkr#static, so decorated static members — andstatic x = input(0)via the synthesized signal path — leaked intopropDecorators.quoted: shouldQuoteName(ts.isStringLiteralLike), so'x'emits"x":while OXC emittedx:— a textual divergence (illegal identifiers like'x-y'were already quoted by the emitter's validity check, so this never produced invalid JS).Change
r#staticclass elements inbuild_prop_decorators_metadata_in(covers both explicit decorators and the synthesized initializer-API path).member_key_namereturns(name, quoted);quotedis true forStringLiteraland bareTemplateLiteralkeys and feeds bothLiteralMapEntry::newcalls.#xmembers were already excluded (no usable key name).Not ported: upstream's
DUPLICATE_DECORATED_PROPERTIESfatal diagnostic — unreachable in practice (the only same-name pair is a getter/setter, which can't both be decorated) and this builder has no diagnostic channel. Can be added later if a reachable path is found.Testing
test_set_class_metadata_prop_decorators_member_shapeasserts instance members stay, string keys emit quoted, and static/private members are excluded (includingstatic x = input(0)).cargo test -p oxc_angular_compiler: 2943 passed, 0 failed.transformAngularFileSync(..., {emitClassMetadata: true}):{instanceProp:[{type:Input}],"str-key":[{type:Input}]}— matching ngtsc.