refactor(javascript): normalize erased expression syntax once

This commit is contained in:
morluto
2026-10-10 01:39:28 +08:00
parent cfb12e47dc
commit b628bba1fa
17 changed files with 313 additions and 205 deletions
@@ -14,6 +14,7 @@ import {
readExactJavaScriptLiteral,
semanticStaticPropertyKey,
semanticStaticPropertyName,
unwrapJavaScriptExpression,
} from "./javascriptAstValues.js";
export interface SemanticProjectedBinding {
@@ -56,15 +57,11 @@ const assignedSourceIs = (node: t.Node, source: t.Node): boolean => {
let value = source;
while (true) {
if (t.isAwaitExpression(value)) value = value.argument;
else if (
t.isParenthesizedExpression(value) ||
t.isTSAsExpression(value) ||
t.isTSTypeAssertion(value) ||
t.isTypeCastExpression(value) ||
t.isTSSatisfiesExpression(value)
)
value = value.expression;
else break;
else {
const unwrapped = unwrapJavaScriptExpression(value).node;
if (unwrapped === value) break;
value = unwrapped;
}
}
return value === node;
};