Add parens around `as` (#1528)

I put it at the same place where `a in b` is handled.

Fixes #1524
master
Christopher Chedeau 2017-05-05 21:39:20 -07:00 committed by GitHub
parent c8984f392a
commit 3d964b18bb
4 changed files with 11 additions and 0 deletions

View File

@ -313,6 +313,7 @@ FPp.needsParens = function() {
return true;
}
// else fall through
case "TSAsExpression":
case "LogicalExpression":
switch (parent.type) {
case "CallExpression":

View File

@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`as.js 1`] = `
const name = (description as DescriptionObject).name || (description as string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const name = (description as DescriptionObject).name || description as string;
`;

View File

@ -0,0 +1 @@
const name = (description as DescriptionObject).name || (description as string);

View File

@ -0,0 +1 @@
run_spec(__dirname, {parser: "typescript"});