Numeric literal callees should keep parens (#141)
* Numeric literal callees should keep parens * Remove isNumber check
This commit is contained in:
1 parent
df99ae56b0
commit
0b70a0f2a3
3 files changed
+18
No files matched your search
@@ -329,6 +329,9 @@ FPp.needsParens = function(assumeExpressionContext) {
|
||||
&& name === "object"
|
||||
&& parent.object === node;
|
||||
|
||||
case "NumericLiteral":
|
||||
return parent.type === "MemberExpression";
|
||||
|
||||
case "AssignmentExpression":
|
||||
case "ConditionalExpression":
|
||||
switch (parent.type) {
|
||||
|
||||
@@ -84,6 +84,11 @@ function test4(flip_times: number): number {
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// parentheses around numeric literal should be preserved
|
||||
function test5(): string {
|
||||
return (100).toString();
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function test1(x: number): number {
|
||||
return -x;
|
||||
@@ -108,5 +113,10 @@ function test4(flip_times: number): number {
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// parentheses around numeric literal should be preserved
|
||||
function test5(): string {
|
||||
return (100).toString();
|
||||
}
|
||||
"
|
||||
`;
|
||||
@@ -21,3 +21,8 @@ function test4(flip_times: number): number {
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// parentheses around numeric literal should be preserved
|
||||
function test5(): string {
|
||||
return (100).toString();
|
||||
}
|
||||
Reference in new issue
Block a user