fix(angular): preserve block-body functions in decorator providers#205
fix(angular): preserve block-body functions in decorator providers#205Brooooooklyn merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 557ff9a92f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Block-body arrow functions and function expressions in decorator properties (e.g., useFactory) were silently having unsupported statements dropped. Only return and expression statements survived, corrupting the function body and causing runtime errors. Add RawSource fallback: when convert_oxc_expression encounters a block-body arrow with unsupported statement types (const, if, for, try/catch, etc.) or a function expression, it preserves the complete source text verbatim via span slicing instead of silently dropping statements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
557ff9a to
fa2c703
Compare
Thread source_text into class metadata builder so decorator arguments containing block-body arrows/function expressions are preserved via RawSource fallback instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa2c7030e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6eabfac5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
- build_ctor_params_metadata: pass source_text so @Inject(...) args with complex expressions are preserved in ɵsetClassMetadata - build_prop_decorators_metadata: pass source_text so @input({...}) with complex transform functions are preserved - extract_provided_in: propagate source_text from parent extract_injectable_metadata into forwardRef extraction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90ccab0a13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
crates/oxc_angular_compiler/src/directive/property_decorators.rs
Outdated
Show resolved
Hide resolved
…back, thread source_text through property decorators
Three reviewer fixes:
1. P1 - RawSource now strips TypeScript type annotations via
parse-transform-codegen pipeline, preventing invalid JS output
like `(dep: Dep) => { ... }` in generated code.
2. Medium - Expression-body arrows with unsupported inner expressions
(e.g., `() => someUnsupportedExpr`) now fall back to RawSource
instead of returning None.
3. P2 - Thread source_text through property_decorators.rs so
@input({transform}), @ViewChild, @ContentChild arguments with
complex expressions are preserved via RawSource fallback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d70418d613
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
- Use SourceType::ts().with_module(true) instead of script-mode ts() so import.meta and ESM-only syntax parse correctly in RawSource fallback expressions. - Add fast path: try parsing as .mjs first. If the expression is already valid JavaScript (no type annotations), return it as-is without running the heavier semantic→transform→codegen pipeline. Only expressions with actual TypeScript syntax pay the full cost. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b9955ebe4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if let Some(rest) = code.strip_prefix("0, (").or_else(|| code.strip_prefix("0,(")) { | ||
| if let Some(inner) = rest.strip_suffix(");") { | ||
| return inner.to_string(); |
There was a problem hiding this comment.
Parse wrapper output without fixed
0,(...) formatting
This unwrapping assumes codegen always returns exactly 0, (expr);, but oxc_codegen can emit forms like 0, function(...) {} or 0, (x) => x; where the wrapper parentheses are normalized away. When that happens, this branch misses and falls back to expr_source, so TypeScript annotations are not stripped and RawSource can re-emit invalid JS (for example useFactory: function(dep: Dep) { ... } keeps : Dep in output).
Useful? React with 👍 / 👎.


Block-body arrow functions and function expressions in decorator properties
(e.g., useFactory) were silently having unsupported statements dropped.
Only return and expression statements survived, corrupting the function body
and causing runtime errors.
Add RawSource fallback: when convert_oxc_expression encounters a block-body
arrow with unsupported statement types (const, if, for, try/catch, etc.) or
a function expression, it preserves the complete source text verbatim via
span slicing instead of silently dropping statements.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Note
Medium Risk
Touches core expression conversion/emission paths and introduces verbatim source emission (
RawSource), which could affect correctness and escaping/formatting for previously-converted expressions.Overview
Fixes metadata/codegen loss where complex expressions inside Angular decorator properties (notably
providers.useFactory) had unsupported statements silently dropped, producing corrupted runtime factories.This threads optional
source_textthrough metadata extraction and expression conversion, and introduces a newOutputExpression::RawSourcefallback that preserves the original expression text (with TypeScript types stripped) when the output AST cannot represent constructs like block-body arrows withconst/if/loops orfunctionexpressions. Emission, cloning, visitors, and optimization passes are updated to treatRawSourceas an opaque leaf, with new unit/integration tests covering the regression (#203).Written by Cursor Bugbot for commit 3b9955e. This will update automatically on new commits. Configure here.