chore: fix mishandled regex const check

This commit is contained in:
Evan You 2025-02-12 15:49:32 +08:00
parent 4121de4960
commit d48706336a
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
1 changed files with 2 additions and 1 deletions

View File

@ -544,7 +544,6 @@ export function isStaticNode(node: Node): boolean {
case 'BooleanLiteral':
case 'NullLiteral':
case 'BigIntLiteral':
case 'RegExpLiteral':
return true
}
return false
@ -558,6 +557,8 @@ export function isConstantNode(node: Node, bindings: BindingMetadata): boolean {
case 'Identifier':
const type = bindings[node.name]
return type === BindingTypes.LITERAL_CONST
case 'RegExpLiteral':
return true
case 'ObjectExpression':
return node.properties.every(prop => {
// { bar() {} } object methods are not considered static nodes