Repository navigation
Conversation
JeanMeche
force-pushed
the
refactor/ngp-printer-parity
branch
from
October 19, 2026 18:20
78e1501 to
8f33588
Compare
mattrbeck
reviewed
Oct 19, 2026
| // mounts every test file under `/virtual_project`. Absolute resource paths that ngtsc emits | ||
| // verbatim (e.g. `ɵɵExternalStylesFeature(["/style-A.css"])`) therefore differ only by this | ||
| // mount prefix; strip it so the comparison is root-agnostic. | ||
| return ( |
Member
There was a problem hiding this comment.
This change definitely makes sense
| o.BinaryOperator.NotIdentical, | ||
| ]); | ||
|
|
||
| const BINARY_OPERATORS = new Map<o.BinaryOperator, string>([ |
Member
There was a problem hiding this comment.
I'm not sure about these changes to the output printer. I like that we can reduce the hackiness of the comparison, but I don't know that we should be re-implementing TypeScript's printer here. Maybe there's a middle-ground of keeping things like stripRedundantClarifyingParens in the normalizer but not doing all of this? Or if we do all of this, borrowing the BINARY_OPERATORS from the compiler rather than duplicating them here?
JeanMeche
force-pushed
the
refactor/ngp-printer-parity
branch
from
October 20, 2026 01:09
8f33588 to
6777066
Compare
…gtsc TS printer Aligns NGP's `ExpressionPrinter` (`output_ast_printer.ts`) with `ngtsc`'s TypeScript AST printer (`ExpressionTranslatorVisitor` + `TypeScriptAstFactory`) by implementing operator-precedence-aware parenthesization, single-line formatting for single-return `FunctionExpr` nodes without leading comments, and `, ` separator spacing for expression lists. Removes `stripRedundantClarifyingParens`, `transformOutsideStringLikeTokens`, Prettier re-formatting in `compliance_spec.ts`, and the ad-hoc parenthesization/comma/factory regexes from `ngp_emit_normalizer.ts` and `expect_emit.ts`.
JeanMeche
force-pushed
the
refactor/ngp-printer-parity
branch
from
October 20, 2026 01:12
6777066 to
c80226b
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
Resolves the
TODO(ngp-parity)inpackages/compiler-cli/src/ngtsc/testing/src/ngp_emit_normalizer.tsby aligning NGP'sExpressionPrinter(packages/compiler-cli/preprocessor/src/output_ast_printer.ts) withngtsc's TypeScript AST printer (ExpressionTranslatorVisitor+TypeScriptAstFactory) and removing the corresponding AST/regex post-processing hacks from test normalizers:EmitterVisitor):AssignmentExpression-permissive positions (top-levelExpressionPrinter.print(),ExpressionStatement,ReturnStatement,DeclareVarStmtinitializer,IfStmtcondition, call/new/comma-separated argument lists, array/object/template literal elements, spread expressions, index accesses, arrow concise bodies, and ternary branches) viawithUnparenthesized().??/&&/||mixing rules (canOmitBinaryOperandParens) to omit redundant parentheses onBinaryOperatorExpr,ConditionalExpr, andUnaryOperatorExprwhile preserving explicitParenthesizedExprnodes and required precedence/associativity grouping.FunctionExprformatting & argument comma spacing:FunctionExprnodes whose body is a singleReturnStatementwithout leading comments on a single line (function(...) { return ...; }), matchingTypeScriptAstFactory.createFunctionExpression.', 'invisitAllExpressions.ngp_emit_normalizer.ts,expect_emit.ts,compliance_spec.ts):stripRedundantClarifyingParens,transformOutsideStringLikeTokens, Prettier re-formatting incompliance_spec.ts, and the ad-hoc parenthesization/factory/comma regexes fromnormalizeNgpEmitForComparisonandnormalizeNgpOutputFile.${...}template literal interpolations (such as$localizeplaceholder expressions) incanonicalizeStringQuotes.