Repository navigation
Conversation
mattrbeck
force-pushed
the
fix/ngp-set-class-metadata-member-decorators
branch
2 times, most recently
from
November 19, 2026 16:01
6ce5d40 to
434606a
Compare
…er decorators Add regression specs verifying that ɵsetClassMetadata and ɵsetClassMetadataAsync are emitted as a trailing IIFE outside the class when surviving non-Angular member, declare-property, or parameter decorators are present, and that private/protected static member accesses (including typeof queries, multi-line and comment-separated return/throw/yield expressions, computed-key shadowing, and namespace-qualified base classes) are guarded without hiding invalid accesses.
… decorators
Include surviving non-Angular member, declare-property, constructor-parameter,
and method-parameter decorators when deciding whether to emit ɵsetClassMetadata
and ɵsetClassMetadataAsync as a trailing IIFE outside the class rather than
inside static { ... }, while keeping non_ng_decorator_spans limited to class
decorators so NG1005 diagnostics in local and declaration-only compilation
modes are unchanged.
When ɵsetClassMetadata moves outside static { ... }, record private/protected
static member accesses on the class hierarchy (including namespace-qualified
base classes and typeof type queries, while ignoring non-literal computed keys)
in outsideMetadataGuards anchored at the property identifier span so // @ts-ignore
suppresses TS2341/TS2445 without ASI hazards.
mattrbeck
force-pushed
the
fix/ngp-set-class-metadata-member-decorators
branch
from
November 19, 2026 21:29
434606a to
c33a906
Compare
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.
ngppreviously only checked class-level decorators (non_ng_decorator_spans) when deciding whether to emitɵsetClassMetadata/ɵsetClassMetadataAsyncas a trailing IIFE outside the class instead of inside astatic { ... }block. When an Angular-decorated class has no custom class decorators, but carries surviving non-Angular member,declareproperty, constructor-parameter, or method-parameter decorators,ngpemittedɵsetClassMetadatainsidestatic { ... }before TypeScript'stslib.__decorate(...)statements ran.ng-analyzenow computeshas_non_angular_decoratorsacross surviving class, constructor-parameter, property/accessor/method, and method-parameter decorators (while keepingnon_ng_decorator_spansseparate soNG1005diagnostics in local / declaration-only compilation remain limited to custom class decorators). WhenɵsetClassMetadatamoves outsidestatic {},privateandprotectedstatic accesses on the class hierarchy (including namespace-qualified base classes andtypeoftype queries) are recorded inoutsideMetadataGuards, anchored at the property identifier span (ClassName.// @ts-ignore\nmember) soTS2341/TS2445is suppressed without ASI hazards.Minimal failure example
Before (
main):After:
Reservations
ngDevMode = false),ɵsetClassMetadatais dead-code-eliminated. Even in dev /TestBed(ngDevMode = true),setClassMetadataonly writesType.{decorators,ctorParameters,propDecorators}on the constructor and never touchesType.prototypeor method descriptors, and standardtslib.__paramignores return values. MovingɵsetClassMetadataoutsidestatic {}for member and method-parameter decorators only changes runtime behavior in two narrow dev-mode cases: (a) a custom decorator that itself writestarget.constructor.propDecorators/decoratorsexpectingsetClassMetadatato merge afterwards rather than be overwritten, or (b) an Angular decorator expression re-emitted inɵsetClassMetadatathat eagerly calls a@Decorated() staticmethod on the same class. Outside of those cases, the primary motivation is matchingngtsc's JS statement order (__decoratebeforeɵsetClassMetadata). ATODOcomment marks the member/method-parameter checks for removal oncengpis the default compiler.static {}: MovingɵsetClassMetadataout ofstatic {}places re-emitted decorator expressions outside the class's lexical access scope.DecoratorReferenceFinderguardsprivate/protectedstatic accesses on the class andprotectedstatic accesses on its base chain with// @ts-ignore, though ECMAScript#privatestatic fields (MyCmp.#TOK->TS18016, whichngtscalso emits outside the class) cannot be suppressed outside the class body, and an inheritedprotected staticmember accessed through a non-direct imported ancestor without local.d.tschasing cannot be verified syntactically.