Repository navigation
fix(directive): emit a dynamic host attribute value as written, like ngtsc - #639
Conversation
…ngtsc ngtsc wraps a host value it can't evaluate in a WrappedNodeExpr and emits it in hostAttrs for a plain attribute; oxc rejected it. Values computed from an import are treated the same way, as ngtsc's local compilation mode does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…etadataSync Host attribute values are now `OutputExpression`s, so the napi crate no longer built (`to_string` on an expression). Report a static value as its string, as before, and a dynamic one (`role: foo.bar()`) as the expression `hostAttrs` emits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… ngtsc
ngtsc emits a host attribute's `DynamicValue` as written, including a
value computed from an import (`foo.bar()`, `SHARED + '!'`, `ns.foo.bar`).
An import named itself (`SHARED`, `ns.SHARED`, `const R = SHARED`) is a
`Reference` instead, which ngtsc rejects in full and local compilation
mode alike when the other file has no readable value ("found unparseable
value"). Keep reporting it as imported, as before this branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #627 (case 1). Cases 2 and 3 in the issue are left unchanged on purpose. The issue explains why.
Problem
ngtsc's
evaluateHostExpressionBindings(compiler-cli/src/ngtsc/annotations/directive/src/shared.ts) turns a host value it can't evaluate (DynamicValue) intoWrappedNodeExpr(value.node).parseHostBindingsemits that expression for a plain attribute (hostAttrs: ["test", test]). oxc stored host attribute values as strings and reported an error. A value computed from an import got the "imported from another module" error instead, with or withoutresolveImportedValues.Fix
evaluate_host_metadatareturns aHostValuefor each entry: a string, or the expression ngtsc would emit. For a plain attribute, a dynamic value (an unknown name, a call, a function expression, or a value computed from an import) becomes its expression. The expression comes fromProp::origin, in the form it can be written where the metadata is compiled.HostMetadata.attributesholdsOutputExpressions, like the directive'sR3HostMetadata.attributesalready does. Full emit and partial emit (host: { attributes: { role: make() } }) both use them.[prop],(event),classandstylekeep ngtsc's "... binding must be string" errors, or the import error.{ ...ns }.Checks
host_metadata_evaluation_test:dynamic_value_of_a_plain_attributenow asserts the emittedhostAttrs. It coversmake(), an unknown name, a spread const, an import, and the ngtsc spec input. It used to assert the error.dynamic_value_of_a_plain_attribute_partialanddynamic_value_of_a_plain_attribute_out_of_scope.host_that_depends_on_an_importno longer expects an error for{ role: SHARED }.cross_file_values_test::dynamic_host_attribute_from_an_unreadable_importports ngtsc_spec.ts "should accept dynamic host attribute bindings" withresolveImportedValues.cargo test -p oxc_angular_compiler --all-features: 3519 passed, 0 failed, 1 ignored.cargo fmtis clean.cargo clippy -p oxc_angular_compiler --all-featuresreports no warnings on the changed lines.🤖 Generated with Claude Code