diff --git a/src/fast-path.js b/src/fast-path.js index 29f125ad..5e982383 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -313,6 +313,7 @@ FPp.needsParens = function() { return true; } // else fall through + case "TSAsExpression": case "LogicalExpression": switch (parent.type) { case "CallExpression": diff --git a/tests/typescript_as/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_as/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..ecc14ee5 --- /dev/null +++ b/tests/typescript_as/__snapshots__/jsfmt.spec.js.snap @@ -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; + +`; diff --git a/tests/typescript_as/as.js b/tests/typescript_as/as.js new file mode 100644 index 00000000..c7e03417 --- /dev/null +++ b/tests/typescript_as/as.js @@ -0,0 +1 @@ +const name = (description as DescriptionObject).name || (description as string); diff --git a/tests/typescript_as/jsfmt.spec.js b/tests/typescript_as/jsfmt.spec.js new file mode 100644 index 00000000..379b0d72 --- /dev/null +++ b/tests/typescript_as/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, {parser: "typescript"});