Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff86547

Browse files
committed
fix: nullish coalescing should be logical expression, not binary
1 parent f21c9b2 commit ff86547

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/typescript-estree/src/convert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ export class Converter {
16761676
| TSESTree.LogicalExpression
16771677
| TSESTree.BinaryExpression
16781678
>(node, {
1679-
type: type,
1679+
type,
16801680
operator: getTextForTokenKind(node.operatorToken.kind)!,
16811681
left: this.converter(
16821682
node.left,

packages/typescript-estree/src/node-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ const ASSIGNMENT_OPERATORS: ts.AssignmentOperator[] = [
2020
SyntaxKind.CaretEqualsToken,
2121
];
2222

23-
const LOGICAL_OPERATORS: ts.LogicalOperator[] = [
23+
const LOGICAL_OPERATORS: (
24+
| ts.LogicalOperator
25+
| ts.SyntaxKind.QuestionQuestionToken)[] = [
2426
SyntaxKind.BarBarToken,
2527
SyntaxKind.AmpersandAmpersandToken,
28+
SyntaxKind.QuestionQuestionToken,
2629
];
2730

2831
const TOKEN_TO_TEXT: { readonly [P in ts.SyntaxKind]?: string } = {

packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65452,7 +65452,7 @@ Object {
6545265452
"type": "Literal",
6545365453
"value": "",
6545465454
},
65455-
"type": "BinaryExpression",
65455+
"type": "LogicalExpression",
6545665456
},
6545765457
"optional": false,
6545865458
"property": Object {
@@ -65621,7 +65621,7 @@ Object {
6562165621
"type": "Literal",
6562265622
"value": "",
6562365623
},
65624-
"type": "BinaryExpression",
65624+
"type": "LogicalExpression",
6562565625
},
6562665626
"optional": false,
6562765627
"property": Object {

0 commit comments

Comments
 (0)