René's URL Explorer Experiment


Title: fix(compiler-cli): emit ɵsetClassMetadata in static blocks in ngtsc by mattrbeck · Pull Request #72136 · angular/angular · GitHub

Open Graph Title: fix(compiler-cli): emit ɵsetClassMetadata in static blocks in ngtsc by mattrbeck · Pull Request #72136 · angular/angular

X Title: fix(compiler-cli): emit ɵsetClassMetadata in static blocks in ngtsc by mattrbeck · Pull Request #72136 · angular/angular

Description: Alternative to #72101: instead of moving ɵsetClassMetadata / ɵsetClassMetadataAsync out of static {} in ngp whenever a class has surviving member or method-parameter decorators, this PR updates ngtsc to emit ɵsetClassMetadata / ɵsetClassMetadataAsync inside a static { ... } block on the class whenever the class is not wrapped by Cls = __decorate(..., Cls) (i.e. when there are no surviving non-Angular class or constructor-parameter decorators). When surviving non-Angular class or constructor-parameter decorators are present, both ngtsc and ngp emit ɵsetClassMetadata as a trailing IIFE after __decorate (ng-analyze adds has_non_angular_ctor_param_decorators so ngp matches ngtsc for constructor-parameter decorators). Because ngtsc and ngp now agree on static {} placement, this also removes the ctx.complianceMode special case for ɵsetClassMetadata in ngp. Split into 3 commits for reviewability: ngtsc & ngp implementation + unit specs (transform.ts, processor.ts, ng-analyze, ngtsc_spec.ts) @angular/build oxc-transform static-block metadata elision (temporary pnpm patch corresponding to upstream PR angular/angular-cli#34770 so full-mode @angular/core classes with static {} metadata continue to be pure-wrapped and tree-shaken) Compliance .js golden updates (expect_emit.ts + 591 compliance goldens) Minimal failure example import {Component} from '@angular/core'; function Log(): MethodDecorator { return (_t, _k, d) => d; } @Component({selector: 'my-cmp', template: ''}) export class MyCmp { @Log() greet() {} } Before (main ngtsc): export class MyCmp { greet() {} static ɵfac = function MyCmp_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyCmp)(); }; static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MyCmp, selectors: [["my-cmp"]], decls: 0, vars: 0, template: function MyCmp_Template(rf, ctx) {} }); } __decorate([ Log() ], MyCmp.prototype, "greet", null); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MyCmp, [{ type: Component, args: [{ selector: 'my-cmp', template: '' }] }], null, null); })(); // On pre-ES2022 targets (e.g. ES2020), `ngp` downleveled `static {}` into an IIFE *before* // `__decorate([Log()], MyCmp.prototype, ...)`, whereas `ngtsc` emitted its IIFE *after* `__decorate`. After (ngtsc & ngp): export class MyCmp { greet() {} static ɵfac = function MyCmp_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyCmp)(); }; static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MyCmp, selectors: [["my-cmp"]], decls: 0, vars: 0, template: function MyCmp_Template(rf, ctx) {} }); static { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MyCmp, [{ type: Component, args: [{ selector: 'my-cmp', template: '' }] }], null, null); } } __decorate([ Log() ], MyCmp.prototype, "greet", null); // On pre-ES2022 targets, TypeScript downlevels `static {}` into an IIFE immediately after `MyCmp.ɵcmp` // and *before* `MyCmp.prototype` `__decorate` in both `ngtsc` and `ngp`. Keeping `ɵsetClassMetadata` // inside `static {}` also keeps any instance `#private` field references in decorator metadata // lexically inside the class body instead of producing a JS `SyntaxError`. Reservations (vs. #72101) Requires @angular/build (oxc-transform) update first (angular/angular-cli#34770): Commit 2 temporarily patches @angular/build via patchedDependencies so oxc-transform removes ngDevMode/ngJitMode-guarded (ɵ)setClassMetadata* StaticBlocks and wraps pure static Angular classes in @angular/core/fesm2022/core.mjs (//packages/core/test/bundling/* and integration/standalone-bootstrap); before landing, angular/angular-cli#34770 should release and roll in normally (which ngp also needs before packages/core switches to ngp). Compliance golden churn & partial-linker divergence: Updating ngtsc modifies 591 compliance .js goldens (and shifts ES5 downleveled ɵsetClassMetadata inside the ES5 class closure right before return Cls;). Partial compilation (GOLDEN_PARTIAL.js) keeps ɵɵngDeclareClassMetadata as a top-level statement after the class to preserve the v12.0.0 partial-declaration format, so linked output still emits a trailing IIFE (normalized in expect_emit.ts via relocateStaticClassMetadataForLinked). Execution order relative to member / static __decorate: In dev / TestBed (ngDevMode = true), ɵsetClassMetadata inside static {} now executes before tslib.__decorate runs on prototype or static members. If an Angular decorator expression re-emitted in ɵsetClassMetadata eagerly calls a @Decorated() static method on the same class, or if a custom member decorator writes directly to target.constructor.propDecorators, ɵsetClassMetadata runs before that decorator rather than after it. Classes wrapped by __decorate still emit outside static {}: While this eliminates the ~600-line OutsideMetadataScope @ts-ignore visibility-tracking machinery needed by #72101 for member and method-parameter decorators, classes with surviving custom class or constructor-parameter decorators still emit ɵsetClassMetadata outside the class after Cls = __decorate([...], Cls).

Open Graph Description: Alternative to #72101: instead of moving ɵsetClassMetadata / ɵsetClassMetadataAsync out of static {} in ngp whenever a class has surviving member or method-parameter decorators, this PR updates ngt...

X Description: Alternative to #72101: instead of moving ɵsetClassMetadata / ɵsetClassMetadataAsync out of static {} in ngp whenever a class has surviving member or method-parameter decorators, this PR updates ngt...

Opengraph URL: https://github.com/angular/angular/pull/72136

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4f4d04bd-92bb-1233-7a25-dccb5765f2c6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8508:A70A9:E66A2D:1310DE2:6B01D343
html-safe-nonce84da99d6823c36d75ec7e5dc39b4ef3e7b3b24f26b461861d422a8fb61c23bc4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTA4OkE3MEE5OkU2NkEyRDoxMzEwREUyOjZCMDFEMzQzIiwidmlzaXRvcl9pZCI6Ijc1MDAzNzYyODIxNDQ4MjIwODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac614d59e57474ec7a8fe646aee841a70120ee2867737169566431744951598978
hovercard-subject-tagpull_request:5408193923
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/angular/angular/pull/72136/files
twitter:imagehttps://avatars.githubusercontent.com/u/22065329?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/22065329?s=400&v=4
og:image:altAlternative to #72101: instead of moving ɵsetClassMetadata / ɵsetClassMetadataAsync out of static {} in ngp whenever a class has surviving member or method-parameter decorators, this PR updates ngt...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angular/pull/72136/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fpull%2F72136%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fpull%2F72136%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/pull/72136/files
Reloadhttps://github.com/angular/angular/pull/72136/files
Reloadhttps://github.com/angular/angular/pull/72136/files
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests142 (142)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fangular%2Fangular%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fangular%2Fangular%2Fissues%2Fnew%2Fchoose
mattrbeckhttps://github.com/mattrbeck
angular:mainhttps://github.com/angular/angular/tree/main
mattrbeck:fix/ngtsc-set-class-metadata-static-blockhttps://github.com/mattrbeck/angular/tree/fix/ngtsc-set-class-metadata-static-block
Conversation 1 https://github.com/angular/angular/pull/72136
Commits 3 https://github.com/angular/angular/pull/72136/commits
Checks 19 https://github.com/angular/angular/pull/72136/checks
Files changed 620 https://github.com/angular/angular/pull/72136/files
fix(compiler-cli): emit ɵsetClassMetadata in static blocks in ngtsc https://github.com/angular/angular/pull/72136/files#top
Show all changes 3 commits https://github.com/angular/angular/pull/72136/files
d168e2f fix(compiler-cli): emit ɵsetClassMetadata in static blocks in ngtsc mattrbeck Nov 20, 2026 https://github.com/angular/angular/pull/72136/commits/d168e2f229a3c14cdd47278c42eb72369fe39a84
ff20f01 build: patch @angular/build oxc-transform for static-block metadata mattrbeck Nov 20, 2026 https://github.com/angular/angular/pull/72136/commits/ff20f0142a5a051e90579c4181b0c4c87f6e022f
418a90a test(compiler-cli): update compliance goldens for static-block metadata mattrbeck Nov 20, 2026 https://github.com/angular/angular/pull/72136/commits/418a90a9f08894e3568075d3bc2ad279e5a9c557
Clear filters https://github.com/angular/angular/pull/72136/files
Please reload this pagehttps://github.com/angular/angular/pull/72136/files
Please reload this pagehttps://github.com/angular/angular/pull/72136/files
MODULE.bazelhttps://github.com/angular/angular/pull/72136/files#diff-6136fc12446089c3db7360e923203dd114b6a1466252e71667c6791c20fe6bdc
View file https://github.com/angular/angular/blob/418a90a9f08894e3568075d3bc2ad279e5a9c557/MODULE.bazel
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular/pull/72136/{{ revealButtonHref }}
https://github.com/angular/angular/pull/72136/files#diff-6136fc12446089c3db7360e923203dd114b6a1466252e71667c6791c20fe6bdc
https://github.com/angular/angular/pull/72136/files#diff-6136fc12446089c3db7360e923203dd114b6a1466252e71667c6791c20fe6bdc
integration/cli-hello-world/patches/@angular+build@22.3.0-rc.0.patchhttps://github.com/angular/angular/pull/72136/files#diff-6cd804b1c084df30d316986e9192f3f23f16209e5dfb361e6d22ef7c9361a7db
View file https://github.com/angular/angular/blob/418a90a9f08894e3568075d3bc2ad279e5a9c557/integration/cli-hello-world/patches/%40angular%2Bbuild%4022.3.0-rc.0.patch
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular/pull/72136/{{ revealButtonHref }}
integration/cli-hello-world/pnpm-lock.yamlhttps://github.com/angular/angular/pull/72136/files#diff-339a048650e22375b3864178a0593fbc3a1135eeaac203d466d9c5b073b2f20b
View file https://github.com/angular/angular/blob/418a90a9f08894e3568075d3bc2ad279e5a9c557/integration/cli-hello-world/pnpm-lock.yaml
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/angular/angular/pull/72136/files
integration/cli-hello-world/pnpm-workspace.yamlhttps://github.com/angular/angular/pull/72136/files#diff-493facedc2565d30d9acb08ac5cbc10b765bf7d595c8ec30a8839ddc9f013c64
View file https://github.com/angular/angular/blob/418a90a9f08894e3568075d3bc2ad279e5a9c557/integration/cli-hello-world/pnpm-workspace.yaml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular/pull/72136/{{ revealButtonHref }}
https://github.com/angular/angular/pull/72136/files#diff-493facedc2565d30d9acb08ac5cbc10b765bf7d595c8ec30a8839ddc9f013c64
Please reload this pagehttps://github.com/angular/angular/pull/72136/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.