forked from prettier/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hug object types in function parameters in Flow like in TS (prettier#…
- Loading branch information
Showing
7 changed files
with
158 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#### An object type in a `declare function` signature now breaks before the return type (#13396 by @thorn0) | ||
|
||
This behavior has been unified with how TypeScript is formatted. | ||
|
||
<!-- prettier-ignore --> | ||
```jsx | ||
// Input | ||
declare function bla (props: { a: boolean, b: string, c: number }): Promise<Array<foo>> | ||
|
||
// Prettier stable | ||
declare function bla(props: { a: boolean, b: string, c: number }): Promise< | ||
Array<foo> | ||
>; | ||
|
||
// Prettier main | ||
declare function bla(props: { | ||
a: boolean; | ||
b: string; | ||
c: number; | ||
}): Promise<Array<foo>>; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/format/flow/function-single-destructuring/object-type-in-declare-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare function foo(this: { a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bazFlip({ a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bar(...{ a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bar(...x: { a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/format/typescript/declare/object-type-in-declare-function.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare function foo(this: { a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bazFlip({ a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bar(...{ a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> | ||
|
||
declare function bar(...x: { a: boolean, b: string, c: number }): | ||
Promise<Array<foo>> |