[MemberExpression] Brackets are required when calling a method on a number
See original GitHub issueReally excited about Prettier! I just ran it against our codebase here at Geckoboard and discovered a few edge case bugs. I’ll open issues for each of the bugs that I can generate a small repro case for.
You can call methods on a number using the following syntax:
(0).toLocaleString();
Prettier currently converts this to:
0.toLocaleString();
Which gives the following syntax error when run in Chrome:
Uncaught SyntaxError: Invalid or unexpected token
I would have expected the output to be:
(0).toLocaleString();
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Can a MemberExpression return a Method - Stack Overflow
I've tried using this with something like: var myClassObject = new MyClass(); Run(myClassObject, o => o.ReturnSomething, new object[ ...
Read more >calling a method with parenthesis vs. no ... - Codecademy
So I keep running into this problem where I will call a method without parenthesis ... as a sort of mini-programme by virtue...
Read more >Expressions — The Swift Programming Language (Swift 5.7)
Postfix expressions, like prefix and infix expressions, let you build up more complex expressions using postfixes such as function calls and member access....
Read more >Tips & Tricks for Writing CUBEVALUE Formulas - Excel Campus
I call this the ice cube method because the CUBEVALUE formulas tend to be smooth ... For example, the following formula references the...
Read more >ECMAScript Spec: 11. Expressions - Interglacial
The elements need not be literals; they are evaluated each time the array ... Call the [[Put]] method of Result(1) with arguments "length"...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is now fixed in 0.0.9
needsParens
is not being called for the binary expression. I think that it’s becauseprintMemberChain
somehow skips it but I don’t understand enough of how it works to be sure.