Skip to content

Commit 596e8d8

Browse files
fix(leaderboard): 日志区分 null 和 object,避免 typeof null 误导
Copilot CR (PR #328) JS 历史包袱:typeof null === "object"。之前 fallback 兜底分支日志写 "kind=object",遇到既有内容是 null 时排查者会误以为是个普通对象,绕半天。 单独识别 null,日志输出 kind=null。 实测三种情况日志输出: - null → kind=null - {...} → kind=object - "str" → kind=string
1 parent b20ea9a commit 596e8d8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

scripts/generate-leaderboard.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ async function main() {
185185
preservedExisting = true;
186186
} else {
187187
// 非数组(对象、字面量、null 等)→ 不 preserve,走下方兜底覆盖空数组
188+
// typeof null === "object" 是 JS 历史包袱,单独标识避免排查时误以为是普通对象
189+
const kind = parsed === null ? "null" : typeof parsed;
188190
console.warn(
189-
`[generate-leaderboard] ${OUTPUT} 已存在但内容不是数组(typeof=${typeof parsed}),按无效数据处理,兜底覆盖为 []。`,
191+
`[generate-leaderboard] ${OUTPUT} 已存在但内容不是数组(kind=${kind}),按无效数据处理,兜底覆盖为 []。`,
190192
);
191193
}
192194
} catch {

0 commit comments

Comments
 (0)