From d5d45f8a96ef381208a2b1504760c66fda23ac62 Mon Sep 17 00:00:00 2001 From: BlankParticle Date: Fri, 14 Aug 2026 17:52:38 +0530 Subject: [PATCH] fix: type error in early hints and add typecheck to CI --- .github/workflows/ci.yml | 1 + benchmarks/fetch/tsconfig.json | 16 ++++++++++++++++ package.json | 1 + src/early-hints.ts | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 benchmarks/fetch/tsconfig.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc48a9e6..1a0a765e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: run_install: true - run: pnpm run format - run: pnpm run lint + - run: pnpm run typecheck - run: pnpm run test ci-build: diff --git a/benchmarks/fetch/tsconfig.json b/benchmarks/fetch/tsconfig.json new file mode 100644 index 00000000..37e1c9c2 --- /dev/null +++ b/benchmarks/fetch/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "ESNext", + "declaration": true, + "moduleResolution": "Bundler", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "types": ["node"], + "noEmit": true + }, + "include": ["src/**/*", "scripts/**/*"] +} diff --git a/package.json b/package.json index 1c4f269e..40fd9dca 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "postbuild": "publint", "prerelease": "pnpm run build && pnpm run test --run", "release": "np --no-publish", + "typecheck": "tsc --noEmit", "lint": "eslint src test", "lint:fix": "eslint src test --fix", "format": "prettier --check \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\"", diff --git a/src/early-hints.ts b/src/early-hints.ts index ecbf026e..9f416f55 100644 --- a/src/early-hints.ts +++ b/src/early-hints.ts @@ -27,7 +27,7 @@ export const earlyHints = ( } const env = c.env || {} - const bindings = (env.server ? env.server : env) as HttpBindings + const bindings = ('server' in env ? env.server : env) as HttpBindings const outgoing = bindings?.outgoing // Capability check: outgoing.writeEarlyHints exists and is a function.