fix(semantics): preserve empty string property keys (#764)

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-07 10:23:43 +08:00
committed by GitHub
parent dd3640548f
commit 630bdafcac
11 changed files with 149 additions and 33 deletions
+5 -5
View File
@@ -14,7 +14,7 @@ import {
} from "./javascriptSemanticState.js";
import { stringValue } from "./javascriptStaticAnalysisHelpers.js";
import { compareCodePoints } from "./canonicalOrdering.js";
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
import { semanticStaticPropertyKey } from "./javascriptAstValues.js";
import {
semanticAmbiguousProvenance,
semanticLocalProvenance,
@@ -170,8 +170,8 @@ const evaluateObject = (
invalidateEarlierProperties();
continue;
}
const name = semanticStaticPropertyName(property.key, property.computed);
if (name === "" && !t.isStringLiteral(property.key, { value: "" })) {
const name = semanticStaticPropertyKey(property.key, property.computed);
if (name === null) {
unknownProperties = true;
if (omittedProperties !== null) omittedProperties += 1;
invalidateEarlierProperties();
@@ -491,8 +491,8 @@ const mergeValues = (
const memberKey = (
node: t.MemberExpression | t.OptionalMemberExpression,
): string | number | undefined => {
const name = semanticStaticPropertyName(node.property, node.computed);
return name === "" ? undefined : name;
const name = semanticStaticPropertyKey(node.property, node.computed);
return name ?? undefined;
};
const nestedContext = (