feat: implement JIT compilation output for transformAngularFile#98
Merged
Brooooooklyn merged 3 commits intomainfrom Mar 9, 2026
Merged
feat: implement JIT compilation output for transformAngularFile#98Brooooooklyn merged 3 commits intomainfrom
Brooooooklyn merged 3 commits intomainfrom
Conversation
When `jit: true` is passed, the compiler now produces Angular JIT-compatible
output instead of AOT-compiled code. This matches the output format of
Angular CLI's JitCompilation class:
- Decorator downleveling via `__decorate` from tslib
- templateUrl/styleUrl replaced with `angular:jit:template:file;` imports
- Constructor params emitted as `static ctorParameters` for runtime DI
- Class restructured to `let X = class X {}; X = __decorate([...], X);`
- Templates are NOT compiled (runtime JIT compiler handles that)
- Import elision disabled (ctor param types needed at runtime)
Closes #97
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
…ypes Fixes two bugs identified in code review: 1. (High) Member decorators (@input, @output, @HostBinding, etc.) were removed from class bodies without being emitted as `static propDecorators`. Angular's JIT runtime reads `propDecorators` to discover inputs/outputs/ queries at runtime — without it, data binding silently breaks. Now emits: static propDecorators = { myInput: [{ type: Input }], myOutput: [{ type: Output }], }; 2. (Medium) `extract_type_name_from_annotation` only skipped TSNullKeyword in union types. For `undefined | T` or `null | undefined | T`, the function encountered TSUndefinedKeyword first, immediately recursed and returned None, never reaching the actual type. Fixed to try each union member and return the first resolvable name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…xpression
Angular's reference filters only `null` literal types from union types
and requires exactly one non-null type to remain. Previously we iterated
all union members and returned the first resolvable one, which is more
permissive than Angular's behavior.
With Angular-aligned semantics:
- `T | null` → resolves to T (1 non-null type remains)
- `undefined | T` → unresolvable (2 non-null types remain)
- `null | undefined | T` → unresolvable (2 non-null types remain)
Unresolvable types emit `{ type: undefined }` matching Angular's
`paramType || ts.factory.createIdentifier('undefined')` fallback.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47a1211 to
56a1f69
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.

When
jit: trueis passed, the compiler now produces Angular JIT-compatibleoutput instead of AOT-compiled code. This matches the output format of
Angular CLI's JitCompilation class:
__decoratefrom tslibangular:jit:template:file;importsstatic ctorParametersfor runtime DIlet X = class X {}; X = __decorate([...], X);Closes #97
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Medium Risk
Introduces a large new transformation/codegen path that changes emitted JS semantics (decorator removal, import insertion, export reshaping), so regressions are possible despite strong test coverage.
Overview
Adds a new
jitcompilation path totransform_angular_filethat emits Angular JIT-compatible JavaScript instead of AOT output.In JIT mode, Angular-decorated classes (
@Component,@Directive,@Pipe,@Injectable,@NgModule) are rewritten tolet X = class X { ... }, have decorators removed from the class body, and get a__decoratecall (with a newimport { __decorate } from "tslib") plus restored exports. ComponenttemplateUrl/styleUrl/styleUrlsare rewritten intoangular:jit:*:file;...imports andtemplate/stylesreferences, and runtime metadata is emitted viastatic ctorParametersandstatic propDecorators(including Angular-like union-type handling for ctor param types).Expands integration coverage with new standalone emission assertions and a comprehensive suite of JIT snapshot tests for templates/resources, class restructuring, DI metadata, and member decorator downleveling.
Written by Cursor Bugbot for commit 56a1f69. This will update automatically on new commits. Configure here.