fix(javascript): bound semantic expansion and resolve lexical receivers

This commit is contained in:
morluto
2026-10-09 00:49:30 +08:00
parent eaf5734083
commit 16f4609d68
26 changed files with 868 additions and 78 deletions
@@ -2,7 +2,10 @@ import * as t from "@babel/types";
import { compareCodePoints } from "../canonicalOrdering.js";
import type { ElectronStaticValue } from "./electronStaticAnalysisTypes.js";
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
import {
readExactJavaScriptLiteral,
semanticStaticPropertyName,
} from "./javascriptAstValues.js";
import { sourceSlice } from "./javascriptStaticAnalysisHelpers.js";
/** Preserve one literal value or the exact inert expression. */
@@ -142,10 +145,9 @@ const literalValue = (
):
| { readonly found: true; readonly value: string | number | boolean | null }
| { readonly found: false } => {
if (t.isStringLiteral(node) || t.isNumericLiteral(node))
return { found: true, value: node.value };
if (t.isBooleanLiteral(node)) return { found: true, value: node.value };
if (t.isNullLiteral(node)) return { found: true, value: null };
if (node === null || node === undefined) return { found: false };
const literal = readExactJavaScriptLiteral(node);
if (literal.found) return literal;
if (t.isTemplateLiteral(node) && node.expressions.length === 0)
return {
found: true,