mirror of https://github.com/vuejs/core.git
build: stricter conditions for UnaryExpression in const enum plugin
This commit is contained in:
parent
a871fd0cc0
commit
b49b9eff20
|
@ -112,9 +112,17 @@ export async function constEnum() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init.type === 'UnaryExpression') {
|
if (init.type === 'UnaryExpression') {
|
||||||
// @ts-ignore assume all operands are literals
|
if (
|
||||||
const exp = `${init.operator}${init.argument.value}`
|
init.argument.type === 'StringLiteral' ||
|
||||||
value = evaluate(exp)
|
init.argument.type === 'NumericLiteral'
|
||||||
|
) {
|
||||||
|
const exp = `${init.operator}${init.argument.value}`
|
||||||
|
value = evaluate(exp)
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
`unhandled UnaryExpression argument type ${init.argument.type} in ${file}`
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
|
|
Loading…
Reference in New Issue