File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,12 +141,14 @@ export class ConditionalExpression extends SlangNode {
141141 // We can remove parentheses only because we are sure that the
142142 // `condition` must be a single `bool` value.
143143 const operandLoc = this . operand . loc ;
144- for (
145- let operandSingleExpression = getOperandSingleExpression ( this . operand ) ;
146- operandSingleExpression &&
147- operandSingleExpression . kind !== NonterminalKind . ConditionalExpression ;
148- operandSingleExpression = getOperandSingleExpression ( this . operand )
149- ) {
144+ for ( let operandSingleExpression ; ; ) {
145+ operandSingleExpression = getOperandSingleExpression ( this . operand ) ;
146+ if (
147+ operandSingleExpression === undefined ||
148+ operandSingleExpression . kind === NonterminalKind . ConditionalExpression
149+ )
150+ break ;
151+
150152 this . operand = operandSingleExpression ;
151153 }
152154 this . operand . loc = operandLoc ;
Original file line number Diff line number Diff line change @@ -35,8 +35,7 @@ export class ModifierInvocation extends SlangNode {
3535
3636 cleanModifierInvocationArguments ( ) : void {
3737 if (
38- this . arguments &&
39- this . arguments . kind === NonterminalKind . PositionalArgumentsDeclaration &&
38+ this . arguments ?. kind === NonterminalKind . PositionalArgumentsDeclaration &&
4039 this . arguments . isEmpty
4140 ) {
4241 delete this . arguments ;
Original file line number Diff line number Diff line change 11import { doc , util } from 'prettier' ;
22import { printComment } from '../slang-comments/printer.js' ;
33import { joinExisting } from '../slang-utils/join-existing.js' ;
4-
54import { locEnd } from '../slang-utils/loc.js' ;
5+
66import type { AstPath , Doc , ParserOptions } from 'prettier' ;
77import type {
88 AstNode ,
@@ -21,8 +21,10 @@ export function printComments(
2121 path : AstPath < StrictAstNode > ,
2222 options : ParserOptions < AstNode >
2323) : Doc [ ] {
24- if ( node . comments === undefined ) return [ ] ;
25- const lastPrintableIndex = node . comments . findLastIndex ( isPrintable ) ;
24+ const lastPrintableIndex = ( node . comments ?? [ ] ) . findLastIndex ( isPrintable ) ;
25+ if ( lastPrintableIndex === - 1 ) {
26+ return [ ] ;
27+ }
2628 return joinExisting (
2729 line ,
2830 path . map ( ( { node : comment } , index ) => {
You can’t perform that action at this time.
0 commit comments