question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parentheses missing on `OptionalMemberExpression`

See original GitHub issue

Prettier 1.19.1 Playground link

--parser babel

Input:

(foo?.bar)();

Output:

foo?.bar();

A case found in #7470

I think they are equal, so we should modify AST to pass test?

@thorn0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thorn0commented, Jan 30, 2020

They’re not equal. If foo is undefined, foo?.bar(); does nothing whereas (foo?.bar)(); turns into undefined() and throws a TypeError (“… is not a function”).

0reactions
thorn0commented, Jan 31, 2020

fixed by #7500

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing parentheses around LogicalExpression when used in ...
Hello! So I have a transform that transforms a.getIn(['b', 'c']) to a?.b?.c (and some more stuff). If instead of a there is a...
Read more >
Why is the parenthesis missing in this anonymous function call?
Since the syntax for function declarations and function expressions is identical, JS tells which one you are using from the code around the ......
Read more >
@babel/types | Yarn - Package Manager
#11325 fix: check parentheses between optional chain and other types (@JLHwung) ... #8751 Fix some missing parens cases with OptionalMemberExpression in ...
Read more >
babel/types
AST Node OptionalMemberExpression shape: ... FunctionParent did not include Program since Babel 7. t.isFunctionParent(node);. Copy. Covered nodes:.
Read more >
parentheses missing from iPhone keypad in Messages app
When you are typing a message, that appears. As iW00 has indicated, typing the parentheses around the area code is not necessary, only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found