Repository navigation
Conversation
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I think the problem here is that we need print parenthesis for some cases. Prettier PR #19916 --parser typescriptInput: (obj.aaa /*
c */)!.substring(0);Output: obj
.aaa /*
c */!
.substring(0);Second Output: SyntaxError: Expression expected. (4:3)
2 | .aaa /*
3 | c */!
> 4 | .substring(0);
| ^
5 | |
| (followingNode?.type === "Identifier" || | ||
| (enclosingNode.computed && | ||
| precedingNode?.type === "TSNonNullExpression" && | ||
| followingNode === enclosingNode.property)) |
| if ( | ||
| currentGroup.length > 0 && | ||
| isMemberExpression(printedNodes[i].node) && | ||
| hasComment(printedNodes[i].node, CommentCheckFlags.Leading) | ||
| ) { | ||
| groups.push(currentGroup); | ||
| currentGroup = []; | ||
| hasSeenCallExpression = false; | ||
| } | ||
|
|
Fixed, see link |
| return false; | ||
| } | ||
|
|
||
| if (shouldAddParenthesesToNonNullOperand(path, options)) { |
There was a problem hiding this comment.
Let's move it to parentNeedsParentheses().
| !needsParentheses(path, options) | ||
| !needsParentheses(path, options) && | ||
| !path.call( | ||
| () => shouldAddParenthesesToNonNullOperand(path, options), |
There was a problem hiding this comment.
Let's call needsParentheses() instead, maybe also check node.type, since we don't want print own comments for other nodes.
|
|
||
| doc = printCommentsForFunction(path, options, doc); | ||
|
|
||
| if (shouldAddParenthesesToNonNullOperand(path, options)) { |
There was a problem hiding this comment.




Description
Fixes #12529
Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.