diff --git a/src/common/fast-path.js b/src/common/fast-path.js index eae670e99..f7f325145 100644 --- a/src/common/fast-path.js +++ b/src/common/fast-path.js @@ -265,6 +265,9 @@ FastPath.prototype.needsParens = function(options) { case "BinaryExpression": return parent.operator === "**" && name === "left"; + case "TSNonNullExpression": + return true; + default: return false; } diff --git a/tests/typescript_non_null/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_non_null/__snapshots__/jsfmt.spec.js.snap index 530b94771..f1171e5aa 100644 --- a/tests/typescript_non_null/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_non_null/__snapshots__/jsfmt.spec.js.snap @@ -20,6 +20,7 @@ const { exports[`parens.ts 1`] = ` (a ? b : c) ![tokenKey]; (a || b) ![tokenKey]; +(void 0)!; async function f() { return (await foo())!; @@ -31,6 +32,7 @@ function* g() { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (a ? b : c)![tokenKey]; (a || b)![tokenKey]; +(void 0)!; async function f() { return (await foo())!; diff --git a/tests/typescript_non_null/parens.ts b/tests/typescript_non_null/parens.ts index 24d3d1087..93ad2f0cc 100644 --- a/tests/typescript_non_null/parens.ts +++ b/tests/typescript_non_null/parens.ts @@ -1,5 +1,6 @@ (a ? b : c) ![tokenKey]; (a || b) ![tokenKey]; +(void 0)!; async function f() { return (await foo())!;