UNPKG

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