Add parenthesis for yield and await inside of `as` (#1915)

Fixes #1913
master
Christopher Chedeau 2017-06-02 15:10:02 -07:00 committed by GitHub
parent 2f9ea794db
commit 74f0d3979b
3 changed files with 21 additions and 1 deletions

View File

@ -354,7 +354,8 @@ FastPath.prototype.needsParens = function() {
case "YieldExpression":
if (
parent.type === "UnaryExpression" ||
parent.type === "AwaitExpression"
parent.type === "AwaitExpression" ||
parent.type === "TSAsExpression"
) {
return true;
}
@ -366,6 +367,7 @@ FastPath.prototype.needsParens = function() {
case "LogicalExpression":
case "SpreadElement":
case "SpreadProperty":
case "TSAsExpression":
return true;
case "MemberExpression":

View File

@ -9,6 +9,12 @@ start + (yearSelectTotal as number)
scrollTop > (visibilityHeight as number)
export default class Column<T> extends (RcTable.Column as React.ComponentClass<ColumnProps<T>>) {}
({}) as {};
function*g() {
const test = (yield 'foo') as number;
}
async function g() {
const test = (await 'foo') as number;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const name = (description as DescriptionObject).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
@ -22,5 +28,11 @@ export default class Column<T> extends (RcTable.Column as React.ComponentClass<
ColumnProps<T>
>) {}
({}) as {};
function* g() {
const test = (yield "foo") as number;
}
async function g() {
const test = (await "foo") as number;
}
`;

View File

@ -6,3 +6,9 @@ start + (yearSelectTotal as number)
scrollTop > (visibilityHeight as number)
export default class Column<T> extends (RcTable.Column as React.ComponentClass<ColumnProps<T>>) {}
({}) as {};
function*g() {
const test = (yield 'foo') as number;
}
async function g() {
const test = (await 'foo') as number;
}