UNPKG

25.9 kBTypeScriptView Raw
1// Type definitions for prettier 2.3
2// Project: https://github.com/prettier/prettier, https://prettier.io
3// Definitions by: Ika <https://github.com/ikatyang>,
4// Ifiok Jr. <https://github.com/ifiokjr>,
5// Florian Imdahl <https://github.com/ffflorian>,
6// Sosuke Suzuki <https://github.com/sosukesuzuki>,
7// Christopher Quadflieg <https://github.com/Shinigami92>
8// Kevin Deisz <https://github.com/kddeisz>
9// Georgii Dolzhykov <https://github.com/thorn0>
10// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
11// TypeScript Version: 3.7
12
13// This utility is here to handle the case where you have an explicit union
14// between string literals and the generic string type. It would normally
15// resolve out to just the string type, but this generic LiteralUnion maintains
16// the intellisense of the original union.
17//
18// It comes from this issue: microsoft/TypeScript#29729:
19// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227
20export type LiteralUnion<T extends U, U = string> = T | (Pick<U, never> & { _?: never });
21
22export type AST = any;
23export type Doc = doc.builders.Doc;
24
25// https://github.com/prettier/prettier/blob/main/src/common/ast-path.js
26
27export class AstPath<T = any> {
28 constructor(value: T);
29 stack: T[];
30 getName(): PropertyKey | null;
31 getValue(): T;
32 getNode(count?: number): T | null;
33 getParentNode(count?: number): T | null;
34 call<U>(callback: (path: this) => U, ...names: PropertyKey[]): U;
35 callParent<U>(callback: (path: this) => U, count?: number): U;
36 each(callback: (path: this, index: number, value: any) => void, ...names: PropertyKey[]): void;
37 map<U>(callback: (path: this, index: number, value: any) => U, ...names: PropertyKey[]): U[];
38 match(...predicates: Array<(node: any, name: string | null, number: number | null) => boolean>): boolean;
39}
40
41/** @deprecated `FastPath` was renamed to `AstPath` */
42export type FastPath<T = any> = AstPath<T>;
43
44export type BuiltInParser = (text: string, options?: any) => AST;
45export type BuiltInParserName =
46 | 'angular'
47 | 'babel-flow'
48 | 'babel-ts'
49 | 'babel'
50 | 'css'
51 | 'espree'
52 | 'flow'
53 | 'glimmer'
54 | 'graphql'
55 | 'html'
56 | 'json-stringify'
57 | 'json'
58 | 'json5'
59 | 'less'
60 | 'lwc'
61 | 'markdown'
62 | 'mdx'
63 | 'meriyah'
64 | 'scss'
65 | 'typescript'
66 | 'vue'
67 | 'yaml';
68export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
69
70export type CustomParser = (text: string, parsers: BuiltInParsers, options: Options) => AST;
71
72export interface Options extends Partial<RequiredOptions> {}
73export interface RequiredOptions extends doc.printer.Options {
74 /**
75 * Print semicolons at the ends of statements.
76 * @default true
77 */
78 semi: boolean;
79 /**
80 * Use single quotes instead of double quotes.
81 * @default false
82 */
83 singleQuote: boolean;
84 /**
85 * Use single quotes in JSX.
86 * @default false
87 */
88 jsxSingleQuote: boolean;
89 /**
90 * Print trailing commas wherever possible.
91 * @default 'es5'
92 */
93 trailingComma: 'none' | 'es5' | 'all';
94 /**
95 * Print spaces between brackets in object literals.
96 * @default true
97 */
98 bracketSpacing: boolean;
99 /**
100 * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
101 * @default false
102 */
103 jsxBracketSameLine: boolean;
104 /**
105 * Format only a segment of a file.
106 * @default 0
107 */
108 rangeStart: number;
109 /**
110 * Format only a segment of a file.
111 * @default Infinity
112 */
113 rangeEnd: number;
114 /**
115 * Specify which parser to use.
116 */
117 parser: LiteralUnion<BuiltInParserName> | CustomParser;
118 /**
119 * Specify the input filepath. This will be used to do parser inference.
120 */
121 filepath: string;
122 /**
123 * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
124 * This is very useful when gradually transitioning large, unformatted codebases to prettier.
125 * @default false
126 */
127 requirePragma: boolean;
128 /**
129 * Prettier can insert a special @format marker at the top of files specifying that
130 * the file has been formatted with prettier. This works well when used in tandem with
131 * the --require-pragma option. If there is already a docblock at the top of
132 * the file then this option will add a newline to it with the @format marker.
133 * @default false
134 */
135 insertPragma: boolean;
136 /**
137 * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
138 * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
139 * @default 'preserve'
140 */
141 proseWrap: 'always' | 'never' | 'preserve';
142 /**
143 * Include parentheses around a sole arrow function parameter.
144 * @default 'always'
145 */
146 arrowParens: 'avoid' | 'always';
147 /**
148 * The plugin API is in a beta state.
149 */
150 plugins: Array<string | Plugin>;
151 /**
152 * How to handle whitespaces in HTML.
153 * @default 'css'
154 */
155 htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
156 /**
157 * Which end of line characters to apply.
158 * @default 'lf'
159 */
160 endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
161 /**
162 * Change when properties in objects are quoted.
163 * @default 'as-needed'
164 */
165 quoteProps: 'as-needed' | 'consistent' | 'preserve';
166 /**
167 * Whether or not to indent the code inside <script> and <style> tags in Vue files.
168 * @default false
169 */
170 vueIndentScriptAndStyle: boolean;
171 /**
172 * Control whether Prettier formats quoted code embedded in the file.
173 * @default 'auto'
174 */
175 embeddedLanguageFormatting: 'auto' | 'off';
176}
177
178export interface ParserOptions<T = any> extends RequiredOptions {
179 locStart: (node: T) => number;
180 locEnd: (node: T) => number;
181 originalText: string;
182}
183
184export interface Plugin<T = any> {
185 languages?: SupportLanguage[];
186 parsers?: { [parserName: string]: Parser<T> };
187 printers?: { [astFormat: string]: Printer<T> };
188 options?: SupportOptions;
189 defaultOptions?: Partial<RequiredOptions>;
190}
191
192export interface Parser<T = any> {
193 parse: (text: string, parsers: { [parserName: string]: Parser }, options: ParserOptions<T>) => T;
194 astFormat: string;
195 hasPragma?: (text: string) => boolean;
196 locStart: (node: T) => number;
197 locEnd: (node: T) => number;
198 preprocess?: (text: string, options: ParserOptions<T>) => string;
199}
200
201export interface Printer<T = any> {
202 print(path: AstPath<T>, options: ParserOptions<T>, print: (path: AstPath<T>) => Doc): Doc;
203 embed?: (
204 path: AstPath<T>,
205 print: (path: AstPath<T>) => Doc,
206 textToDoc: (text: string, options: Options) => Doc,
207 options: ParserOptions<T>,
208 ) => Doc | null;
209 insertPragma?: (text: string) => string;
210 /**
211 * @returns `null` if you want to remove this node
212 * @returns `void` if you want to use modified newNode
213 * @returns anything if you want to replace the node with it
214 */
215 massageAstNode?: (node: any, newNode: any, parent: any) => any;
216 hasPrettierIgnore?: (path: AstPath<T>) => boolean;
217 canAttachComment?: (node: T) => boolean;
218 willPrintOwnComments?: (path: AstPath<T>) => boolean;
219 printComment?: (commentPath: AstPath<T>, options: ParserOptions<T>) => Doc;
220 handleComments?: {
221 ownLine?: (
222 commentNode: any,
223 text: string,
224 options: ParserOptions<T>,
225 ast: T,
226 isLastComment: boolean,
227 ) => boolean;
228 endOfLine?: (
229 commentNode: any,
230 text: string,
231 options: ParserOptions<T>,
232 ast: T,
233 isLastComment: boolean,
234 ) => boolean;
235 remaining?: (
236 commentNode: any,
237 text: string,
238 options: ParserOptions<T>,
239 ast: T,
240 isLastComment: boolean,
241 ) => boolean;
242 };
243}
244
245export interface CursorOptions extends Options {
246 /**
247 * Specify where the cursor is.
248 */
249 cursorOffset: number;
250 rangeStart?: never;
251 rangeEnd?: never;
252}
253
254export interface CursorResult {
255 formatted: string;
256 cursorOffset: number;
257}
258
259/**
260 * `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
261 */
262export function format(source: string, options?: Options): string;
263
264/**
265 * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
266 * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
267 */
268export function check(source: string, options?: Options): boolean;
269
270/**
271 * `formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code.
272 * This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
273 *
274 * The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`.
275 */
276export function formatWithCursor(source: string, options: CursorOptions): CursorResult;
277
278export interface ResolveConfigOptions {
279 /**
280 * If set to `false`, all caching will be bypassed.
281 */
282 useCache?: boolean;
283 /**
284 * Pass directly the path of the config file if you don't wish to search for it.
285 */
286 config?: string;
287 /**
288 * If set to `true` and an `.editorconfig` file is in your project,
289 * Prettier will parse it and convert its properties to the corresponding prettier configuration.
290 * This configuration will be overridden by `.prettierrc`, etc. Currently,
291 * the following EditorConfig properties are supported:
292 * - indent_style
293 * - indent_size/tab_width
294 * - max_line_length
295 */
296 editorconfig?: boolean;
297}
298
299/**
300 * `resolveConfig` can be used to resolve configuration for a given source file,
301 * passing its path as the first argument. The config search will start at the
302 * file path and continue to search up the directory.
303 * (You can use `process.cwd()` to start searching from the current directory).
304 *
305 * A promise is returned which will resolve to:
306 *
307 * - An options object, providing a [config file](https://prettier.io/docs/en/configuration.html) was found.
308 * - `null`, if no file was found.
309 *
310 * The promise will be rejected if there was an error parsing the configuration file.
311 */
312export function resolveConfig(filePath: string, options?: ResolveConfigOptions): Promise<Options | null>;
313export namespace resolveConfig {
314 function sync(filePath: string, options?: ResolveConfigOptions): Options | null;
315}
316
317/**
318 * `resolveConfigFile` can be used to find the path of the Prettier configuration file,
319 * that will be used when resolving the config (i.e. when calling `resolveConfig`).
320 *
321 * A promise is returned which will resolve to:
322 *
323 * - The path of the configuration file.
324 * - `null`, if no file was found.
325 *
326 * The promise will be rejected if there was an error parsing the configuration file.
327 */
328export function resolveConfigFile(filePath?: string): Promise<string | null>;
329export namespace resolveConfigFile {
330 function sync(filePath?: string): string | null;
331}
332
333/**
334 * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache.
335 * Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
336 */
337export function clearConfigCache(): void;
338
339export interface SupportLanguage {
340 name: string;
341 since?: string;
342 parsers: BuiltInParserName[] | string[];
343 group?: string;
344 tmScope?: string;
345 aceMode?: string;
346 codemirrorMode?: string;
347 codemirrorMimeType?: string;
348 aliases?: string[];
349 extensions?: string[];
350 filenames?: string[];
351 linguistLanguageId?: number;
352 vscodeLanguageIds?: string[];
353}
354
355export interface SupportOptionRange {
356 start: number;
357 end: number;
358 step: number;
359}
360
361export type SupportOptionType = 'int' | 'boolean' | 'choice' | 'path';
362
363export interface BaseSupportOption<Type extends SupportOptionType> {
364 readonly name?: string;
365 since: string;
366 category: string;
367 /**
368 * The type of the option.
369 *
370 * When passing a type other than the ones listed below, the option is
371 * treated as taking any string as argument, and `--option <${type}>` will
372 * be displayed in --help.
373 */
374 type: Type;
375 /**
376 * Indicate that the option is deprecated.
377 *
378 * Use a string to add an extra message to --help for the option,
379 * for example to suggest a replacement option.
380 */
381 deprecated?: true | string;
382 /**
383 * Description to be displayed in --help. If omitted, the option won't be
384 * shown at all in --help.
385 */
386 description?: string;
387}
388
389export interface IntSupportOption extends BaseSupportOption<'int'> {
390 default: number;
391 array?: false;
392 range?: SupportOptionRange;
393}
394
395export interface IntArraySupportOption extends BaseSupportOption<'int'> {
396 default: Array<{ value: number[] }>;
397 array: true;
398}
399
400export interface BooleanSupportOption extends BaseSupportOption<'boolean'> {
401 default: boolean;
402 array?: false;
403 description: string;
404 oppositeDescription?: string;
405}
406
407export interface BooleanArraySupportOption extends BaseSupportOption<'boolean'> {
408 default: Array<{ value: boolean[] }>;
409 array: true;
410}
411
412export interface ChoiceSupportOption<Value = any> extends BaseSupportOption<'choice'> {
413 default: Value | Array<{ since: string; value: Value }>;
414 description: string;
415 choices: Array<{
416 since?: string;
417 value: Value;
418 description: string;
419 }>;
420}
421
422export interface PathSupportOption extends BaseSupportOption<'path'> {
423 default: string;
424 array?: false;
425}
426
427export interface PathArraySupportOption extends BaseSupportOption<'path'> {
428 default: Array<{ value: string[] }>;
429 array: true;
430}
431
432export type SupportOption =
433 | IntSupportOption
434 | IntArraySupportOption
435 | BooleanSupportOption
436 | BooleanArraySupportOption
437 | ChoiceSupportOption
438 | PathSupportOption
439 | PathArraySupportOption;
440
441export interface SupportOptions extends Record<string, SupportOption> {}
442
443export interface SupportInfo {
444 languages: SupportLanguage[];
445 options: SupportOption[];
446}
447
448export interface FileInfoOptions {
449 ignorePath?: string;
450 withNodeModules?: boolean;
451 plugins?: string[];
452 resolveConfig?: boolean;
453}
454
455export interface FileInfoResult {
456 ignored: boolean;
457 inferredParser: string | null;
458}
459
460export function getFileInfo(filePath: string, options?: FileInfoOptions): Promise<FileInfoResult>;
461
462export namespace getFileInfo {
463 function sync(filePath: string, options?: FileInfoOptions): FileInfoResult;
464}
465
466/**
467 * Returns an object representing the parsers, languages and file types Prettier supports for the current version.
468 */
469export function getSupportInfo(): SupportInfo;
470
471/**
472 * `version` field in `package.json`
473 */
474export const version: string;
475
476// https://github.com/prettier/prettier/blob/main/src/common/util-shared.js
477export namespace util {
478 interface SkipOptions {
479 backwards?: boolean;
480 }
481
482 type Quote = "'" | '"';
483
484 function addDanglingComment(node: any, comment: any, marker: any): void;
485 function addLeadingComment(node: any, comment: any): void;
486 function addTrailingComment(node: any, comment: any): void;
487 function getAlignmentSize(value: string, tabWidth: number, startIndex?: number): number;
488 function getIndentSize(value: string, tabWidth: number): number;
489 function getMaxContinuousCount(str: string, target: string): number;
490 function getNextNonSpaceNonCommentCharacterIndex<N>(
491 text: string,
492 node: N,
493 locEnd: (node: N) => number,
494 ): number | false;
495 function getStringWidth(text: string): number;
496 function hasNewline(text: string, index: number, opts?: SkipOptions): boolean;
497 function hasNewlineInRange(text: string, start: number, end: number): boolean;
498 function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean;
499 function isNextLineEmpty<N>(text: string, node: N, locEnd: (node: N) => number): boolean;
500 function isNextLineEmptyAfterIndex(text: string, index: number): boolean;
501 function isPreviousLineEmpty<N>(text: string, node: N, locStart: (node: N) => number): boolean;
502 function makeString(rawContent: string, enclosingQuote: Quote, unescapeUnnecessaryEscapes?: boolean): string;
503 function skip(chars: string | RegExp): (text: string, index: number | false, opts?: SkipOptions) => number | false;
504 function skipEverythingButNewLine(text: string, index: number | false, opts?: SkipOptions): number | false;
505 function skipInlineComment(text: string, index: number | false): number | false;
506 function skipNewline(text: string, index: number | false, opts?: SkipOptions): number | false;
507 function skipSpaces(text: string, index: number | false, opts?: SkipOptions): number | false;
508 function skipToLineEnd(text: string, index: number | false, opts?: SkipOptions): number | false;
509 function skipTrailingComment(text: string, index: number | false): number | false;
510 function skipWhitespace(text: string, index: number | false, opts?: SkipOptions): number | false;
511}
512
513// https://github.com/prettier/prettier/blob/main/src/document/index.js
514export namespace doc {
515 namespace builders {
516 type DocCommand =
517 | Align
518 | BreakParent
519 | Concat
520 | Cursor
521 | Fill
522 | Group
523 | IfBreak
524 | Indent
525 | IndentIfBreak
526 | Label
527 | Line
528 | LineSuffix
529 | LineSuffixBoundary
530 | Trim;
531 type Doc = string | Doc[] | DocCommand;
532
533 interface Align {
534 type: 'align';
535 contents: Doc;
536 n: number | string | { type: 'root' };
537 }
538
539 interface BreakParent {
540 type: 'break-parent';
541 }
542
543 interface Concat {
544 type: 'concat';
545 parts: Doc[];
546 }
547
548 interface Cursor {
549 type: 'cursor';
550 placeholder: symbol;
551 }
552
553 interface Fill {
554 type: 'fill';
555 parts: Doc[];
556 }
557
558 interface Group {
559 type: 'group';
560 contents: Doc;
561 break: boolean;
562 expandedStates: Doc[];
563 }
564
565 interface HardlineWithoutBreakParent extends Line {
566 hard: true;
567 }
568
569 interface IfBreak {
570 type: 'if-break';
571 breakContents: Doc;
572 flatContents: Doc;
573 }
574
575 interface Indent {
576 type: 'indent';
577 contents: Doc;
578 }
579
580 interface IndentIfBreak {
581 type: 'indent-if-break';
582 }
583
584 interface Label {
585 type: 'label';
586 }
587
588 interface Line {
589 type: 'line';
590 soft?: boolean;
591 hard?: boolean;
592 literal?: boolean;
593 }
594
595 interface LineSuffix {
596 type: 'line-suffix';
597 contents: Doc;
598 }
599
600 interface LineSuffixBoundary {
601 type: 'line-suffix-boundary';
602 }
603
604 interface LiterallineWithoutBreakParent extends Line {
605 hard: true;
606 literal: true;
607 }
608
609 interface Softline extends Line {
610 soft: true;
611 }
612
613 interface Trim {
614 type: 'trim';
615 }
616
617 interface GroupOptions {
618 shouldBreak?: boolean;
619 id?: symbol;
620 }
621
622 function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
623 /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
624 function align(widthOrString: Align['n'], doc: Doc): Align;
625 /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
626 const breakParent: BreakParent;
627 /**
628 * @see [concat](https://github.com/prettier/prettier/blob/main/commands.md#deprecated-concat)
629 * @deprecated use `Doc[]` instead
630 */
631 function concat(docs: Doc[]): Concat;
632 /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
633 function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
634 /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
635 function dedent(doc: Doc): Align;
636 /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
637 function dedentToRoot(doc: Doc): Align;
638 /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
639 function fill(docs: Doc[]): Fill;
640 /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
641 function group(doc: Doc, opts?: GroupOptions): Group;
642 /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
643 const hardline: Concat;
644 /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
645 const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
646 /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
647 function ifBreak(ifBreak: Doc, noBreak?: Doc, options?: { groupId?: symbol }): IfBreak;
648 /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
649 function indent(doc: Doc): Indent;
650 /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
651 function indentIfBreak(doc: Doc, opts: { groupId: symbol; negate?: boolean }): IndentIfBreak;
652 /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
653 function join(sep: Doc, docs: Doc[]): Concat;
654 /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
655 function label(label: string, doc: Doc): Label;
656 /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
657 const line: Line;
658 /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
659 function lineSuffix(suffix: Doc): LineSuffix;
660 /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
661 const lineSuffixBoundary: LineSuffixBoundary;
662 /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
663 const literalline: Concat;
664 /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
665 const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
666 /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
667 function markAsRoot(doc: Doc): Align;
668 /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
669 const softline: Softline;
670 /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
671 const trim: Trim;
672 /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
673 const cursor: Cursor;
674 }
675 namespace debug {
676 function printDocToDebug(doc: Doc): string;
677 }
678 namespace printer {
679 function printDocToString(
680 doc: Doc,
681 options: Options,
682 ): {
683 formatted: string;
684 cursorNodeStart?: number;
685 cursorNodeText?: string;
686 };
687 interface Options {
688 /**
689 * Specify the line length that the printer will wrap on.
690 * @default 80
691 */
692 printWidth: number;
693 /**
694 * Specify the number of spaces per indentation-level.
695 * @default 2
696 */
697 tabWidth: number;
698 /**
699 * Indent lines with tabs instead of spaces
700 * @default false
701 */
702 useTabs: boolean;
703 parentParser?: string;
704 __embeddedInHtml?: boolean;
705 }
706 }
707 namespace utils {
708 function cleanDoc(doc: Doc): Doc;
709 function findInDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T, defaultValue: T): T;
710 function getDocParts(doc: Doc): Doc;
711 function isConcat(doc: Doc): boolean;
712 function isEmpty(doc: Doc): boolean;
713 function isLineNext(doc: Doc): boolean;
714 function mapDoc<T = Doc>(doc: Doc, callback: (doc: Doc) => T): T;
715 function normalizeDoc(doc: Doc): Doc;
716 function normalizeParts(parts: Doc[]): Doc[];
717 function propagateBreaks(doc: Doc): void;
718 function removeLines(doc: Doc): Doc;
719 function replaceNewlinesWithLiterallines(doc: Doc): Doc;
720 function stripTrailingHardline(doc: Doc): Doc;
721 function traverseDoc(
722 doc: Doc,
723 onEnter?: (doc: Doc) => void | boolean,
724 onExit?: (doc: Doc) => void,
725 shouldTraverseConditionalGroups?: boolean,
726 ): void;
727 function willBreak(doc: Doc): boolean;
728 }
729}