@@ -8,14 +8,25 @@ interface CompilerOptions {
8
8
directives ?: Record < string , DirectiveFunction > ;
9
9
preserveWhitespace ?: boolean ;
10
10
whitespace ?: 'preserve' | 'condense' ;
11
+ outputSourceRange ?: any
11
12
}
12
13
13
- interface CompiledResult {
14
+ interface CompilerOptionsWithSourceRange extends CompilerOptions {
15
+ outputSourceRange : true
16
+ }
17
+
18
+ interface ErrorWithRange {
19
+ msg : string ;
20
+ start : number ;
21
+ end : number ;
22
+ }
23
+
24
+ interface CompiledResult < ErrorType > {
14
25
ast : ASTElement | undefined ;
15
26
render : string ;
16
27
staticRenderFns : string [ ] ;
17
- errors : string [ ] ;
18
- tips : string [ ] ;
28
+ errors : ErrorType [ ] ;
29
+ tips : ErrorType [ ] ;
19
30
}
20
31
21
32
interface CompiledResultFunctions {
@@ -202,21 +213,37 @@ export interface SFCDescriptor {
202
213
/*
203
214
* Exposed functions
204
215
*/
216
+ export function compile (
217
+ template : string ,
218
+ options : CompilerOptionsWithSourceRange
219
+ ) : CompiledResult < ErrorWithRange >
220
+
205
221
export function compile (
206
222
template : string ,
207
223
options ?: CompilerOptions
208
- ) : CompiledResult ;
224
+ ) : CompiledResult < string > ;
209
225
210
226
export function compileToFunctions ( template : string ) : CompiledResultFunctions ;
211
227
228
+ export function ssrCompile (
229
+ template : string ,
230
+ options : CompilerOptionsWithSourceRange
231
+ ) : CompiledResult < ErrorWithRange > ;
232
+
212
233
export function ssrCompile (
213
234
template : string ,
214
235
options ?: CompilerOptions
215
- ) : CompiledResult ;
236
+ ) : CompiledResult < string > ;
216
237
217
238
export function ssrCompileToFunctions ( template : string ) : CompiledResultFunctions ;
218
239
219
240
export function parseComponent (
220
241
file : string ,
221
242
options ?: SFCParserOptions
222
243
) : SFCDescriptor ;
244
+
245
+ export function generateCodeFrame (
246
+ template : string ,
247
+ start : number ,
248
+ end : number
249
+ ) : string ;
0 commit comments