From 4b95c408ae67820ba450e5f409139ccb471ff268 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sun, 24 May 2020 22:27:25 +0800 Subject: [PATCH] Add test for #6988 (#8391) * Add test for #6988 * Move files --- .../__snapshots__/jsfmt.spec.js.snap | 79 +++++++++++++++++++ .../typescript/intersection/type-arguments.ts | 10 +++ 2 files changed, 89 insertions(+) create mode 100644 tests/typescript/intersection/type-arguments.ts diff --git a/tests/typescript/intersection/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/intersection/__snapshots__/jsfmt.spec.js.snap index 34c9fa1ab..1a258900c 100644 --- a/tests/typescript/intersection/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/intersection/__snapshots__/jsfmt.spec.js.snap @@ -196,3 +196,82 @@ type D6 /*0*/ = /*1*/ a & b; ================================================================================ `; + +exports[`type-arguments.ts - {"semi":false} format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 +semi: false + | printWidth +=====================================input====================================== +// #6988 + +// functional component with ugly linebreak +export const MyLongNamedReactFunctionalComponent1: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent2: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent3: FunctionComponent = (props) => {} + +=====================================output===================================== +// #6988 + +// functional component with ugly linebreak +export const MyLongNamedReactFunctionalComponent1: FunctionComponent< + ALongNamedInterface1 & ALongNamedInterface2 +> = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent2: FunctionComponent< + ALongNamedInterface1 | ALongNamedInterface2 +> = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent3: FunctionComponent< + ALongNamedInterface1, + ALongNamedInterface2 +> = (props) => {} + +================================================================================ +`; + +exports[`type-arguments.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +// #6988 + +// functional component with ugly linebreak +export const MyLongNamedReactFunctionalComponent1: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent2: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent3: FunctionComponent = (props) => {} + +=====================================output===================================== +// #6988 + +// functional component with ugly linebreak +export const MyLongNamedReactFunctionalComponent1: FunctionComponent< + ALongNamedInterface1 & ALongNamedInterface2 +> = (props) => {}; + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent2: FunctionComponent< + ALongNamedInterface1 | ALongNamedInterface2 +> = (props) => {}; + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent3: FunctionComponent< + ALongNamedInterface1, + ALongNamedInterface2 +> = (props) => {}; + +================================================================================ +`; diff --git a/tests/typescript/intersection/type-arguments.ts b/tests/typescript/intersection/type-arguments.ts new file mode 100644 index 000000000..4bb831553 --- /dev/null +++ b/tests/typescript/intersection/type-arguments.ts @@ -0,0 +1,10 @@ +// #6988 + +// functional component with ugly linebreak +export const MyLongNamedReactFunctionalComponent1: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent2: FunctionComponent = (props) => {} + +// functional component with valid linebreak +export const MyLongNamedReactFunctionalComponent3: FunctionComponent = (props) => {}