From 56fea10e476dd07968d6a9f8e4aa0079cbdb75d0 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 27 Nov 2023 02:44:36 +0800 Subject: [PATCH] core: contest: apply default value for contestRule.applyProjection --- packages/hydrooj/src/model/contest.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/hydrooj/src/model/contest.ts b/packages/hydrooj/src/model/contest.ts index e4eaec48..122a04f9 100644 --- a/packages/hydrooj/src/model/contest.ts +++ b/packages/hydrooj/src/model/contest.ts @@ -73,7 +73,7 @@ export function isExtended(tdoc: Tdoc) { function buildContestRule(def: Optional, 'applyProjection'>): ContestRule; function buildContestRule(def: Partial>, baseRule: ContestRule): ContestRule; function buildContestRule(def: Partial>, baseRule: ContestRule = {} as any) { - const base = baseRule._originalRule || {}; + const base = baseRule._originalRule || { applyProjection: (_, rdoc) => rdoc }; const funcs = ['scoreboard', 'scoreboardRow', 'scoreboardHeader', 'stat', 'applyProjection']; const f = {}; const rule = { ...baseRule, ...def }; @@ -82,7 +82,6 @@ function buildContestRule(def: Partial>, baseRule: ContestRule rule[key] = f[key].bind(rule); } rule._originalRule = f; - rule.applyProjection ||= (_, rdoc) => rdoc; return rule; }