Fix unstable embedded template literals (#13532)

This commit is contained in:
Georgii Dolzhykov authored and GitHub committed 2022-09-26 16:24:41 +03:00
1 parent 822f354ceb
commit 6d4d011252
22 files changed
+243 -62

No files matched your search

+4 -2
View File
@@ -276,13 +276,15 @@ It doesn't make sense to apply `indentIfBreak` to the current group because "ind
_Added in v2.3.0_
```ts
declare function label(label: string, doc: Doc): Doc;
declare function label(label: any, doc: Doc): Doc;
```
Mark a doc with a string label. This doesn't affect how the doc is printed, but can be useful for heuristics based on doc introspection.
Mark a doc with an arbitrary truthy value. This doesn't affect how the doc is printed, but can be useful for heuristics based on doc introspection.
E.g., to decide how to print an assignment expression, we might want to know whether its right-hand side has been printed as a method call chain, not as a plain function call. If the method chain printing code uses `label` to mark its result, checking that condition can be as easy as `rightHandSideDoc.label === 'method-chain'`.
If the `label` argument is falsy, `doc` is returned as is, without wrapping.
### `hardlineWithoutBreakParent` and `literallineWithoutBreakParent`
_Added in v2.3.0_