( content: SimpleExpressionNode['content'], isStatic: SimpleExpressionNode['isStatic'] = false, loc: SourceLocation, constType: ConstantTypes = ConstantTypes.NOT_CONSTANT, parseMode = ExpParseMode.Normal, )
| 969 | } |
| 970 | |
| 971 | function createExp( |
| 972 | content: SimpleExpressionNode['content'], |
| 973 | isStatic: SimpleExpressionNode['isStatic'] = false, |
| 974 | loc: SourceLocation, |
| 975 | constType: ConstantTypes = ConstantTypes.NOT_CONSTANT, |
| 976 | parseMode = ExpParseMode.Normal, |
| 977 | ) { |
| 978 | const exp = createSimpleExpression(content, isStatic, loc, constType) |
| 979 | if ( |
| 980 | !__BROWSER__ && |
| 981 | !isStatic && |
| 982 | currentOptions.prefixIdentifiers && |
| 983 | parseMode !== ExpParseMode.Skip && |
| 984 | content.trim() |
| 985 | ) { |
| 986 | if (isSimpleIdentifier(content)) { |
| 987 | exp.ast = null // fast path |
| 988 | return exp |
| 989 | } |
| 990 | try { |
| 991 | const plugins = currentOptions.expressionPlugins |
| 992 | const options: BabelOptions = { |
| 993 | plugins: plugins ? [...plugins, 'typescript'] : ['typescript'], |
| 994 | } |
| 995 | if (parseMode === ExpParseMode.Statements) { |
| 996 | // v-on with multi-inline-statements, pad 1 char |
| 997 | exp.ast = parse(` ${content} `, options).program |
| 998 | } else if (parseMode === ExpParseMode.Params) { |
| 999 | exp.ast = parseExpression(`(${content})=>{}`, options) |
| 1000 | } else { |
| 1001 | // normal exp, wrap with parens |
| 1002 | exp.ast = parseExpression(`(${content})`, options) |
| 1003 | } |
| 1004 | } catch (e: any) { |
| 1005 | exp.ast = false // indicate an error |
| 1006 | emitError(ErrorCodes.X_INVALID_EXPRESSION, loc.start.offset, e.message) |
| 1007 | } |
| 1008 | } |
| 1009 | return exp |
| 1010 | } |
| 1011 | |
| 1012 | function emitError(code: ErrorCodes, index: number, message?: string) { |
| 1013 | currentOptions.onError( |
no test coverage detected