2022-02-09 23:02:47 -03:00
|
|
|
#### Improve printing of comments in type aliases in Flow & TS (#12268 by @duailibe)
|
|
|
|
|
|
|
|
|
|
For Flow, the comments will now be more aligned to how we print comments in assignments where the right-hand side is an object expression:
|
|
|
|
|
|
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
|
```js
|
|
|
|
|
// Input
|
|
|
|
|
type Props = // comment explaining the props
|
|
|
|
|
{
|
|
|
|
|
isPlaying: boolean
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prettier stable
|
|
|
|
|
// comment explaining the props
|
|
|
|
|
type Props = {
|
|
|
|
|
isPlaying: boolean,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prettier main
|
|
|
|
|
type Props =
|
|
|
|
|
// comment explaining the props
|
|
|
|
|
{
|
|
|
|
|
isPlaying: boolean,
|
|
|
|
|
};
|
|
|
|
|
```
|
|
|
|
|
|
2022-03-16 13:25:48 +09:00
|
|
|
This change also fixes an issue where a similarly-placed comment in TypeScript would be moved again after a second formatting operation:
|
2022-02-09 23:02:47 -03:00
|
|
|
|
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
|
```ts
|
|
|
|
|
// Input
|
|
|
|
|
type Props = // comment explaining the props
|
|
|
|
|
{
|
|
|
|
|
isPlaying: boolean
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prettier stable
|
|
|
|
|
type Props = { // comment explaining the props
|
|
|
|
|
isPlaying: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prettier stable (2nd format)
|
|
|
|
|
type Props = {
|
|
|
|
|
// comment explaining the props
|
|
|
|
|
isPlaying: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Prettier main
|
|
|
|
|
type Props =
|
|
|
|
|
// comment explaining the props
|
|
|
|
|
{
|
|
|
|
|
isPlaying: boolean,
|
|
|
|
|
};
|
|
|
|
|
```
|