fix(conformance): preserve own JSON keys during comparison (#573)

This commit is contained in:
Kaoru0822
2026-10-05 21:42:26 +08:00
committed by GitHub
parent f5013c50ca
commit 3460eda9ca
3 changed files with 91 additions and 5 deletions
+5 -5
View File
@@ -319,11 +319,11 @@ function sortKeys(value: unknown): unknown {
if (value === null || typeof value !== "object") return value;
if (Array.isArray(value)) return value.map(sortKeys);
if (!isRecord(value)) return value;
const sorted: Record<string, unknown> = {};
for (const key of Object.keys(value).sort()) {
sorted[key] = sortKeys(value[key]);
}
return sorted;
return Object.fromEntries(
Object.keys(value)
.sort()
.map((key) => [key, sortKeys(value[key])]),
);
}
/**