-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrecast.d.ts
161 lines (142 loc) · 5.5 KB
/
recast.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
declare module 'recast' {
export type ParserOptions = any;
export interface PrinterOptions {
/**
* If you want to use a different branch of esprima, or any other
* module that supports a .parse function, pass that module object to
* recast.parse as options.parser (legacy synonym: options.esprima).
* @default require("../parsers/esprima")
*/
parser: Parser;
/**
* Number of spaces the pretty-printer should use per tab for
* indentation. If you do not pass this option explicitly, it will be
* (quite reliably!) inferred from the original code.
* @default 4
*/
tabWidth: number;
/**
* If you really want the pretty-printer to use tabs instead of
* spaces, make this option true.
* @default false
*/
useTabs: boolean;
/**
* The reprinting code leaves leading whitespace untouched unless it
* has to reindent a line, or you pass false for this option.
* @default true
*/
reuseWhitespace: boolean;
/**
* Override this option to use a different line terminator, e.g. \r\n.
* @default require('os').EOL
*/
lineTerminator: string;
/**
* Some of the pretty-printer code (such as that for printing function
* parameter lists) makes a valiant attempt to prevent really long
* lines. You can adjust the limit by changing this option; however,
* there is no guarantee that line length will fit inside this limit.
* @default 74
*/
wrapColumn: number;
/**
* Pass a string as options.sourceFileName to recast.parse to tell the
* reprinter to keep track of reused code so that it can construct a
* source map automatically.
* @default null
*/
sourceFileName: string | null;
/**
* Pass a string as options.sourceMapName to recast.print, and
* (provided you passed options.sourceFileName earlier) the
* PrintResult of recast.print will have a .map property for the
* generated source map.
* @default null
*/
sourceMapName: string | null;
/**
* If provided, this option will be passed along to the source map
* generator as a root directory for relative source file paths.
* @default null
*/
sourceRoot: string | null;
/**
* If you provide a source map that was generated from a previous call
* to recast.print as options.inputSourceMap, the old source map will
* be composed with the new source map.
* @default null
*/
inputSourceMap: string | null;
/**
* If you want esprima to generate .range information (recast only
* uses .loc internally), pass true for this option.
* @default false
*/
range: boolean;
/**
* If you want esprima not to throw exceptions when it encounters
* non-fatal errors, keep this option true.
* @default true
*/
tolerant: boolean;
/**
* If you want to override the quotes used in string literals, specify
* either "single", "double", or "auto" here ("auto" will select the one
* which results in the shorter literal)
* Otherwise, double quotes are used.
* @default 'double'
*/
quote: 'single' | 'double' | 'auto';
// Controls the printing of trailing commas in object literals,
// array expressions and function parameters.
//
// This option could either be:
// * Boolean - enable/disable in all contexts (objects, arrays and function params).
// * Object - enable/disable per context.
/**
* Controls the printing of trailing commas in object literals,
* array expressions and function parameters.
* This option could either be:
* * Boolean - enable/disable in all contexts (objects, arrays and function params).
* * Object - enable/disable per context.
* @default false
*/
trailingComma:
| boolean
| {
objects: boolean;
arrays: boolean;
parameters: boolean;
};
/**
* Controls the printing of spaces inside array brackets.
* @see http://eslint.org/docs/rules/array-bracket-spacing
* @default false
*/
arrayBracketSpacing: boolean;
/**
* Controls the printing of spaces inside object literals,
* destructuring assignments, and import/export specifiers.
* @see http://eslint.org/docs/rules/object-curly-spacing
* @default true
*/
objectCurlySpacing: boolean;
/**
* If you want parenthesis to wrap single-argument arrow function parameter
* lists, pass true for this option.
* @default false
*/
arrowParensAlways: boolean;
/**
* There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
* The use of commas is in line with the more popular style and matches
* how objects are defined in JS, making it a bit more natural to write.
* @default true
*/
flowObjectCommas: boolean;
}
export interface Parser {
parse(source: string, options?: ParserOptions): any;
}
}