Repository navigation
fix(compiler): downlevel jit:true on anonymous classes too - #552
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Upstream's jitDeclarationRegistry has no name requirement — an
anonymous decorated class (only expressible as
`export default class {}`) still opts out of AOT and downlevels
through the JIT path. Drop the class.id gates in both the AOT
jit-forced dispatch and whole-file JIT mode, synthesizing a
default_N name (TypeScript's convention) that avoids the file's
top-level bindings.
Brooooooklyn
force-pushed
the
fix/issue-549-anonymous-jit
branch
from
October 6, 2026 16:20
381eb35 to
79c372a
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.
Summary
jit: trueon an anonymous class fell through to AOT: the jit-forced dispatch was gated onclass.id.is_some(), and whole-file JIT mode skipped nameless classes entirely.Upstream nuance verified against vendored ngtsc sources:
TypeScriptReflectionHost.isClassrequiresnode.name, so anonymous decorated classes are never visited by theTraitCompiler—jitDeclarations.addis unreachable for them and noɵfac/ɵcmpis emitted. Their decorators still downlevel through TypeScript's own decorator emit, which produces exactly the shape this change emits (let default_1 = class ...; default_1 = __decorate([...], default_1); export default default_1;), so routing anonymous jit classes through the existing jit-forced downlevel pipeline restores the net ngtsc output — no Ivy definition,__decoratefor Angular + foreign decorators — with the added benefit ofctorParameters/propDecoratorsstatics.This change:
class.idgates in both paths and synthesizes a name (default_N, TypeScript's own convention for anonymous default exports) whenclass.idis absent.top_level_binding_names, which collects the file's imports (import x = require(),export * as Xincluded) and top-level declaration bindings incl. destructured patterns andvars hoisted out of nested blocks/loops.jit_class_editsno longer searches for theclass/abstractkeywords inside decorator spans —class.span.startincludes leading decorators, so a rawfind("class")could land inside decorator text (e.g.@my.class(...)). For abstract classes only theabstracttoken after the last decorator is removed, since class expressions can't be abstract.@Injectableon an anonymous jit class still skipsɵfac/ɵprov— matching upstream, whoseextractInjectableMetadatareadsclazz.name.textand is unreachable for anonymous classes (they never reach the handler).Test plan
cargo test -p oxc_angular_compiler— 41 binaries green;cargo check --workspaceclean.pnpm --filter @oxc-angular/compare compare --fixtures— 100% pass across all 23 categories.test_jit_true_anonymous_default_export(AOT jit:true),test_jit_mode_anonymous_default_export(options.jit),test_jit_true_anonymous_name_collision(default_1taken →default_2),test_jit_true_abstract_class(named + anonymous abstract jit:true).Fixes #549