Repository navigation
fix(compiler): ignore @HostBinding/@HostListener on static members - #545
Merged
Merged
Conversation
ngtsc's `filterToMembersWithDecorator` filters `!member.isStatic` before
collecting decorated members, so `@HostBinding('class.b') static b` and
`@HostListener('scroll') static onScroll()` never become host bindings
upstream (packages/compiler-cli src/ngtsc/reflection/src/typescript.ts,
used by directive/src/shared.ts:626,693).
OXC's `extract_host_bindings_in`/`extract_host_listeners_in` didn't check
`r#static`, so a decorated static member emitted a `ɵɵclassProp`/`ɵɵlistener`
and was counted in `hostVars`. Both extractors now skip static class
elements, matching upstream. Private (`#x`) members can't carry
decorators and were already unreachable via `get_property_key_name`.
Fixes #544
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Oct 6, 2026
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 #544.
Problem
@HostBinding/@HostListeneronstaticmembers were collected as real host bindings:extract_host_bindings_in/extract_host_listeners_innever checkedr#static, so@HostBinding('class.b') static bemittedɵɵclassProp("b", ctx.b)and inflatedhostVars, while ngtsc'sfilterToMembersWithDecorator(!member.isStatic, typescript.ts:621, used bydirective/src/shared.ts:626,693) ignores static members entirely.Change
Both extractors now carry
r#staticthrough the element match andcontinueon static members. Private#xmembers were already unreachable (get_property_key_namereturnsNoneforPrivateIdentifier, and decorators can't appear on private elements anyway).Testing
test_static_host_binding_and_listener_are_ignored: instance@HostBinding('class.a')+@HostListener('click')still emit; static counterparts produce noclassProp/listenerandhostVarsdrops 4→2.cargo test -p oxc_angular_compiler: 2944 passed, 0 failed; conformance 1264/1264.transformAngularFileSync: the staticb/scrollentries are gone fromhostBindingswhilea/clickremain.