File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
packages/compiler-core/src Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -692,7 +692,7 @@ export function createCallExpression<T extends CallExpression['callee']>(
692
692
loc,
693
693
callee,
694
694
arguments : args
695
- } as any
695
+ } as InferCodegenNodeType < T >
696
696
}
697
697
698
698
export function createFunctionExpression (
Original file line number Diff line number Diff line change @@ -17,20 +17,24 @@ export function defaultOnWarn(msg: CompilerError) {
17
17
__DEV__ && console . warn ( `[Vue warn] ${ msg . message } ` )
18
18
}
19
19
20
+ type InferCompilerError < T > = T extends ErrorCodes
21
+ ? CoreCompilerError
22
+ : CompilerError
23
+
20
24
export function createCompilerError < T extends number > (
21
25
code : T ,
22
26
loc ?: SourceLocation ,
23
27
messages ?: { [ code : number ] : string } ,
24
28
additionalMessage ?: string
25
- ) : T extends ErrorCodes ? CoreCompilerError : CompilerError {
29
+ ) : InferCompilerError < T > {
26
30
const msg =
27
31
__DEV__ || ! __BROWSER__
28
32
? ( messages || errorMessages ) [ code ] + ( additionalMessage || `` )
29
33
: code
30
- const error = new SyntaxError ( String ( msg ) ) as CompilerError
34
+ const error = new SyntaxError ( String ( msg ) ) as InferCompilerError < T >
31
35
error . code = code
32
36
error . loc = loc
33
- return error as any
37
+ return error
34
38
}
35
39
36
40
export const enum ErrorCodes {
You can’t perform that action at this time.
0 commit comments