From 12ba99720714ef965c2c9580a6d922519bc282f8 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Sun, 3 Nov 2019 14:05:08 +0200 Subject: [PATCH] disable optimization from #6229 for calls with type arguments (#6791) --- src/language-js/printer-estree.js | 4 +++- .../__snapshots__/jsfmt.spec.js.snap | 20 +++++++++++++++++++ tests/break-calls/type_args.js | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/break-calls/type_args.js diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 4bbb9193..5000bde1 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -4024,7 +4024,9 @@ function printArgumentsList(path, options, print) { somePrintedArgumentsWillBreak ? breakParent : "", conditionalGroup( [ - !somePrintedArgumentsWillBreak + !somePrintedArgumentsWillBreak && + !node.typeArguments && + !node.typeParameters ? simpleConcat : ifBreak(allArgsBrokenOut(), simpleConcat), shouldGroupFirst diff --git a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap index 5eddc00e..033f231d 100644 --- a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap +++ b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap @@ -231,3 +231,23 @@ function MyComponent(props) { ================================================================================ `; + +exports[`type_args.js 1`] = ` +====================================options===================================== +parsers: ["flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +const response = something.$http.get( + \`api/foo.ashx/foo-details/\${myId}\`, + { cache: quux.httpCache, timeout } +); + +=====================================output===================================== +const response = something.$http.get( + \`api/foo.ashx/foo-details/\${myId}\`, + { cache: quux.httpCache, timeout } +); + +================================================================================ +`; diff --git a/tests/break-calls/type_args.js b/tests/break-calls/type_args.js new file mode 100644 index 00000000..503013f0 --- /dev/null +++ b/tests/break-calls/type_args.js @@ -0,0 +1,4 @@ +const response = something.$http.get( + `api/foo.ashx/foo-details/${myId}`, + { cache: quux.httpCache, timeout } +);