forked from prettier/prettier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix leading comments in mapped types with
readonly
(Cherry-pick pre…
- Loading branch information
Showing
5 changed files
with
193 additions
and
7 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,22 @@ | ||
#### Fix leading comments in mapped types with `readonly` (#13427 by @thorn0, @sosukesuzuki) | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
// Input | ||
type Type = { | ||
// comment | ||
readonly [key in Foo]; | ||
}; | ||
|
||
// Prettier stable | ||
type Type = { | ||
readonly // comment | ||
[key in Foo]; | ||
}; | ||
|
||
// Prettier main | ||
type Type = { | ||
// comment | ||
readonly [key in 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
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,51 @@ | ||
type Type = { | ||
// comment | ||
readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment1 | ||
// comment2 | ||
readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
+readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
-readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
+ readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
+readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
readonly [T in number]; | ||
}; | ||
|
||
type Type = { | ||
// comment | ||
[T in number]; | ||
}; | ||
|
||
type Type = { | ||
readonly | ||
// comment | ||
[T in number]; | ||
}; | ||
|
||
type Type = { | ||
readonly // foo | ||
/* bar */ [T in number]; | ||
}; |