Repository navigation
fix(linker): native ?. for v22 declarations, lazy NgModule lists - #668
Conversation
…sts lazily - Like Angular's linker, `?.` in the template and host bindings of a component or directive declared at v22 or later links natively, giving `undefined`. Before v22, or with a linker before v22.0.0-next.10, it stays `a == null ? null : a.b`. - `ɵɵdefineNgModule`'s declarations, imports and exports are `() => [...]`: a module and a component file that import each other load in either order. Angular's linker leaves them out; we keep them for components that read them at runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Wrap an optional chain that tags a template literal in parentheses, `(ctx.a?.b)`t``, as Babel prints it: `ctx.a?.b`t`` is a syntax error. - Read a declaration's `version` like Angular's linker, with npm's semver: a quoted key, surrounding spaces and a leading `v` too. - Return a sequence or an object literal from a lazy NgModule list in parentheses. 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: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ 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". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ 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". |
Follow-up to #665: fixes the two linker gaps it listed.
1.
?.links the legacy way for v22 declarationsOur linker always expanded
a?.btoa == null ? null : a.b(givesnull). Angular 22's linker uses native?.(givesundefined) for declarations at v22 or later.semver: a quoted"version"key, surrounding spaces and a leadingvare accepted.(ctx.a?.b)t, the way Babel prints it. `ctx.a?.b`tis a syntax error. This bug was already in full mode at v22; native?.would have brought it into the linker.2. NgModule ↔ component import cycle throws
declarations/imports/exportsout. We keep them: components compiled by Oxc (ɵɵgetComponentDepsFactory) read an NgModule'sexportsat runtime. Without them you get NG0302.@angular/core22 (DepsTracker, NgModuleRef, TestBed, JIT checks) goes throughmaybeUnwrapFn, so function lists are safe. This was checked with real runs: NgModule and standalone apps, bootstrap, routerloadChildren,importProvidersFrom, TestBed, dev mode on and off.bootstrapstays eager unless a field is a forward declaration, as in Angular. Forward declarations now use Angular's() => [...]form instead offunction() { return [...]; }.Verification
linker-ng-module-scope-runtime.test.ts:nodeprocess, because Vitest's module runner hides TDZ errors.{{ o?.a?.b === undefined }}givestrue(wasfalse).Cannot access 'App' before initialization).?.result matched once the tagged-template fix was in.cross_file_elision), napi tests (419), conformance 1264/1264.Not in this PR
ɵinj.importsstill copiesexportsas written, like ngtsc's local compilation. So a module that exports a class from the cycle still throws. ngtsc's full build keeps only NgModules there, but that filter needs type info and the code is shared with full mode.0.0.0-PLACEHOLDERdeclaration counts as the latest version, as our standalone and OnPush defaults already do. Angular's shipped linker reads it as v0.ɵɵsetNgModuleScopeis eager and not guarded byngJitMode.🤖 Generated with Claude Code