We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a871fd0 commit b49b9efCopy full SHA for b49b9ef
scripts/const-enum.js
@@ -112,9 +112,17 @@ export async function constEnum() {
112
}
113
114
if (init.type === 'UnaryExpression') {
115
- // @ts-ignore assume all operands are literals
116
- const exp = `${init.operator}${init.argument.value}`
117
- value = evaluate(exp)
+ if (
+ init.argument.type === 'StringLiteral' ||
+ init.argument.type === 'NumericLiteral'
118
+ ) {
119
+ const exp = `${init.operator}${init.argument.value}`
120
+ value = evaluate(exp)
121
+ } else {
122
+ throw new Error(
123
+ `unhandled UnaryExpression argument type ${init.argument.type} in ${file}`
124
+ )
125
+ }
126
127
128
if (value === undefined) {
0 commit comments