Properly add parenthesis for as inside of binary expression (#1698)

The binary logic doesn't work if the node isn't a binary or logical expression
master
Christopher Chedeau 2017-05-23 18:36:14 -07:00 committed by GitHub
parent cd60e020c3
commit 7cd0b78fe7
3 changed files with 14 additions and 1 deletions

View File

@ -340,6 +340,10 @@ FPp.needsParens = function() {
case "BinaryExpression":
case "LogicalExpression": {
if (!node.operator) {
return true;
}
const po = parent.operator;
const pp = util.getPrecedence(po);
const no = node.operator;

View File

@ -4,11 +4,17 @@ exports[`as.js 1`] = `
const name = (description as DescriptionObject).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
(originalError ? wrappedError(errMsg, originalError) : Error(errMsg)) as InjectionError;
'current' in (props.pagination as Object)
start + (yearSelectTotal as number)
scrollTop > (visibilityHeight as number)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const name = (description as DescriptionObject).name || description as string;
const name = (description as DescriptionObject).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
(originalError
? wrappedError(errMsg, originalError)
: Error(errMsg)) as InjectionError;
"current" in (props.pagination as Object);
start + (yearSelectTotal as number);
scrollTop > (visibilityHeight as number);
`;

View File

@ -1,3 +1,6 @@
const name = (description as DescriptionObject).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
(originalError ? wrappedError(errMsg, originalError) : Error(errMsg)) as InjectionError;
'current' in (props.pagination as Object)
start + (yearSelectTotal as number)
scrollTop > (visibilityHeight as number)