From e195aee5d21fe7307de2786856806a7db3b42259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E7=91=BE?= <74231782+sj817@users.noreply.github.com> Date: Sat, 18 Apr 2026 00:08:12 +0800 Subject: [PATCH] fix: remove TS overloads incompatible with --experimental-strip-types, fix 204 response, fix retention-days - lib/github.ts: Remove getEnv overload signatures (Node.js experimental-strip-types does not support TS function overloads, causes SyntaxError at parse time) - lib/github.ts: Handle 204 No Content in request (DELETE returns 204, calling response.json() on empty body throws) - build-pr.yml: retention-days 7->5 (repo max is 5) --- .github/scripts/lib/github.ts | 8 ++++++-- .github/workflows/build-pr.yml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/scripts/lib/github.ts b/.github/scripts/lib/github.ts index 3c21b36f7..a20f97247 100644 --- a/.github/scripts/lib/github.ts +++ b/.github/scripts/lib/github.ts @@ -71,6 +71,11 @@ export class GitHubAPI { throw new Error(`GitHub API error: ${response.status} ${response.statusText}`); } + // 204 No Content(DELETE 等)不解析 body + if (response.status === 204) { + return undefined as T; + } + return response.json() as Promise; } @@ -278,8 +283,7 @@ export function setMultilineOutput (name: string, value: string): void { // ============== 环境变量工具 ============== -export function getEnv (name: string, required: true): string; -export function getEnv (name: string, required?: false): string | undefined; +// Note: 不使用函数重载——Node.js --experimental-strip-types 不支持 TS overload signatures export function getEnv (name: string, required = false): string | undefined { const value = process.env[name]; if (required && !value) { diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 05677e141..caebddbdf 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -191,7 +191,7 @@ jobs: with: name: NapCat.Framework path: workspace/framework-dist - retention-days: 7 # 保留 7 天 + retention-days: 5 # 保留 5 天(仓库上限) # --------------------------------------------------------------------------- # Job 4: 构建 Shell 包 @@ -263,7 +263,7 @@ jobs: with: name: NapCat.Shell path: workspace/shell-dist - retention-days: 7 # 保留 7 天 + retention-days: 5 # 保留 5 天(仓库上限) # --------------------------------------------------------------------------- # Job 5: 更新评论为构建结果 @@ -370,7 +370,7 @@ jobs: with: name: install-script path: ./release-assets/install.sh - retention-days: 7 + retention-days: 5 if-no-files-found: ignore # ---------------------------------------------------------------------------