diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index a85e7327..0d805b32 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -1030,7 +1030,7 @@ function printPathNoParens(path, options, print, args) { isNew ? "new " : "", path.call(print, "callee"), optional, - path.call(print, "typeParameters"), + printFunctionTypeParameters(path, options, print), concat(["(", join(", ", path.map(print, "arguments")), ")"]) ]); } @@ -3583,6 +3583,9 @@ function printTypeAnnotation(path, options, print) { function printFunctionTypeParameters(path, options, print) { const fun = path.getValue(); + if (fun.typeArguments) { + return path.call(print, "typeArguments"); + } if (fun.typeParameters) { return path.call(print, "typeParameters"); } diff --git a/tests/flow_typeapp_call/__snapshots__/jsfmt.spec.js.snap b/tests/flow_typeapp_call/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..48d6a530 --- /dev/null +++ b/tests/flow_typeapp_call/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,42 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typeapp_call.js 1`] = ` +//@flow +f(); +f; +new C; +f(e); +o[e](); +f(x)(y); +async () => {}; +async (): T => {} +new C(e); +f[e]; +new C(); +o.m(); +f.0; +o?.m(e); +o.m?.(e); +async(); +f?.(e); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//@flow +f(); +f < T > ; +new C(); +f(e); +o[e](); +f(x)(y); +async () => {}; +async (): T => {}; +new C(e); +f < T > [e]; +new C(); +o.m(); +f < T > 0.0; +o?.m(e); +o.m?.(e); +async(); +f?.(e); + +`; diff --git a/tests/flow_typeapp_call/jsfmt.spec.js b/tests/flow_typeapp_call/jsfmt.spec.js new file mode 100644 index 00000000..b9a90898 --- /dev/null +++ b/tests/flow_typeapp_call/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["flow"]); diff --git a/tests/flow_typeapp_call/typeapp_call.js b/tests/flow_typeapp_call/typeapp_call.js new file mode 100644 index 00000000..f0b0f9ac --- /dev/null +++ b/tests/flow_typeapp_call/typeapp_call.js @@ -0,0 +1,18 @@ +//@flow +f(); +f; +new C; +f(e); +o[e](); +f(x)(y); +async () => {}; +async (): T => {} +new C(e); +f[e]; +new C(); +o.m(); +f.0; +o?.m(e); +o.m?.(e); +async(); +f?.(e);