From 596e8d85ea2d0df79f4a5f30648fec33855e2a4a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:55:18 +0000 Subject: [PATCH] =?UTF-8?q?fix(leaderboard):=20=E6=97=A5=E5=BF=97=E5=8C=BA?= =?UTF-8?q?=E5=88=86=20null=20=E5=92=8C=20object=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20typeof=20null=20=E8=AF=AF=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copilot CR (PR #328) JS 历史包袱:typeof null === "object"。之前 fallback 兜底分支日志写 "kind=object",遇到既有内容是 null 时排查者会误以为是个普通对象,绕半天。 单独识别 null,日志输出 kind=null。 实测三种情况日志输出: - null → kind=null - {...} → kind=object - "str" → kind=string --- scripts/generate-leaderboard.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/generate-leaderboard.mjs b/scripts/generate-leaderboard.mjs index 2172bf0..5972e8c 100644 --- a/scripts/generate-leaderboard.mjs +++ b/scripts/generate-leaderboard.mjs @@ -185,8 +185,10 @@ async function main() { preservedExisting = true; } else { // 非数组(对象、字面量、null 等)→ 不 preserve,走下方兜底覆盖空数组 + // typeof null === "object" 是 JS 历史包袱,单独标识避免排查时误以为是普通对象 + const kind = parsed === null ? "null" : typeof parsed; console.warn( - `[generate-leaderboard] ${OUTPUT} 已存在但内容不是数组(typeof=${typeof parsed}),按无效数据处理,兜底覆盖为 []。`, + `[generate-leaderboard] ${OUTPUT} 已存在但内容不是数组(kind=${kind}),按无效数据处理,兜底覆盖为 []。`, ); } } catch {