Commit 120197e
committed
fix: surround template literal type expressions with newlines on multi-line
When a template literal type's `${...}` placeholder contains an expression
that does not fit on a single line (notably a `TsUnionType` or
`TsIntersectionType`), the generator broke on the separator (`|` / `&`)
without adding the surrounding newlines + indent that `BinExpr`,
`CondExpr`, etc. already trigger. This produced output like
export type SortSelector = `${
| typeof Descending
| typeof Ascending}${SortItems}`;
instead of
export type SortSelector = `${
typeof Descending | typeof Ascending
}${SortItems}`;
Adding `TsUnionType` and `TsIntersectionType` to
`get_possible_surround_newlines` reuses the existing
`surround_with_newlines_indented_if_multi_line` codepath, so the union
expression stays on one line whenever it fits inside the indented inner
column and otherwise gets a clean indented block — matching how
`BinExpr` is already handled.
Closes denoland/deno#298681 parent f7dd1f3 commit 120197e
2 files changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3279 | 3279 | | |
3280 | 3280 | | |
3281 | 3281 | | |
| 3282 | + | |
3282 | 3283 | | |
3283 | 3284 | | |
3284 | 3285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments