@@ -8,14 +8,25 @@ interface CompilerOptions {
88 directives ?: Record < string , DirectiveFunction > ;
99 preserveWhitespace ?: boolean ;
1010 whitespace ?: 'preserve' | 'condense' ;
11+ outputSourceRange ?: any
1112}
1213
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 > {
1425 ast : ASTElement | undefined ;
1526 render : string ;
1627 staticRenderFns : string [ ] ;
17- errors : string [ ] ;
18- tips : string [ ] ;
28+ errors : ErrorType [ ] ;
29+ tips : ErrorType [ ] ;
1930}
2031
2132interface CompiledResultFunctions {
@@ -202,21 +213,37 @@ export interface SFCDescriptor {
202213/*
203214 * Exposed functions
204215 */
216+ export function compile (
217+ template : string ,
218+ options : CompilerOptionsWithSourceRange
219+ ) : CompiledResult < ErrorWithRange >
220+
205221export function compile (
206222 template : string ,
207223 options ?: CompilerOptions
208- ) : CompiledResult ;
224+ ) : CompiledResult < string > ;
209225
210226export function compileToFunctions ( template : string ) : CompiledResultFunctions ;
211227
228+ export function ssrCompile (
229+ template : string ,
230+ options : CompilerOptionsWithSourceRange
231+ ) : CompiledResult < ErrorWithRange > ;
232+
212233export function ssrCompile (
213234 template : string ,
214235 options ?: CompilerOptions
215- ) : CompiledResult ;
236+ ) : CompiledResult < string > ;
216237
217238export function ssrCompileToFunctions ( template : string ) : CompiledResultFunctions ;
218239
219240export function parseComponent (
220241 file : string ,
221242 options ?: SFCParserOptions
222243) : SFCDescriptor ;
244+
245+ export function generateCodeFrame (
246+ template : string ,
247+ start : number ,
248+ end : number
249+ ) : string ;
0 commit comments