π Search Terms
- nullish coalescing
- boolean operation
- parenthesis
π Version & Regression Information
β― Playground Link
https://stackblitz.com/edit/vitejs-vite-a11yrnds?file=package.json,src%2Fmain.ts
π» Code
import * as ts from 'typescript';
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
const src = ts.createSourceFile('test.ts', '', ts.ScriptTarget.Latest);
const nullishOrNode = ts.factory.createExpressionStatement(
ts.factory.createBinaryExpression(
ts.factory.createBinaryExpression(
ts.factory.createIdentifier('a'),
ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
ts.factory.createIdentifier('b')
),
ts.factory.createToken(ts.SyntaxKind.BarBarToken),
ts.factory.createIdentifier('d')
)
);
// (a ? b : c) || d
const nullishOr = printer.printNode(
ts.EmitHint.Unspecified,
nullishOrNode,
src
);
π Actual behavior
To output: a ?? b || d;
π Expected behavior
To output: (a ?? b) || d;
Additional information about the issue
This change as a breaking change by an Angular user after updating to TS 5.9 angular/angular#63287
π Search Terms
π Version & Regression Information
β― Playground Link
https://stackblitz.com/edit/vitejs-vite-a11yrnds?file=package.json,src%2Fmain.ts
π» Code
π Actual behavior
To output:
a ?? b || d;π Expected behavior
To output:
(a ?? b) || d;Additional information about the issue
This change as a breaking change by an Angular user after updating to TS 5.9 angular/angular#63287