From 303fcf66ff8ffd8f79038a652e13cbf4f3a604e2 Mon Sep 17 00:00:00 2001 From: Andrew Lee <5784515+andyrewlee@users.noreply.github.com> Date: Sat, 5 Dec 2026 04:43:30 -0800 Subject: [PATCH 1/2] Share Workers types with the host application --- bun.lock | 3 ++- package.json | 3 ++- scripts/check-consumer.mjs | 9 +++++++++ test/standalone/imported-state.mts | 4 ++++ test/standalone/package.json | 2 +- test/standalone/tsconfig.imported-state.json | 7 +++++++ 6 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 test/standalone/imported-state.mts create mode 100644 test/standalone/tsconfig.imported-state.json diff --git a/bun.lock b/bun.lock index aca7683..fec5e00 100644 --- a/bun.lock +++ b/bun.lock @@ -9,7 +9,6 @@ "@checkfu/integrations": "0.0.2", "@checkfu/sdk": "0.0.2", "@cloudflare/computer": "0.11.4", - "@cloudflare/workers-types": "5.20261118.1", "@earendil-works/chord": "1.7.0", "@earendil-works/pi-ai": "1.7.0", "@earendil-works/pi-codemode": "1.7.0", @@ -23,6 +22,7 @@ }, "devDependencies": { "@alchemy.run/cloudflare": "2.0.0-beta.87", + "@cloudflare/workers-types": "5.20261118.1", "@effect/platform-node": "4.1.7", "@effect/sql-d1": "4.1.7", "@effect/tsgo": "0.73.2", @@ -36,6 +36,7 @@ }, "peerDependencies": { "@alchemy.run/cloudflare": "*", + "@cloudflare/workers-types": "^5.20261118.1", "rolldown": "^1.2.16", }, "optionalPeers": [ diff --git a/package.json b/package.json index 5890305..579c6d0 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "@checkfu/integrations": "0.0.2", "@checkfu/sdk": "0.0.2", "@cloudflare/computer": "0.11.4", - "@cloudflare/workers-types": "5.20261118.1", "@earendil-works/chord": "1.7.0", "@earendil-works/pi-ai": "1.7.0", "@earendil-works/pi-codemode": "1.7.0", @@ -112,6 +111,7 @@ }, "devDependencies": { "@alchemy.run/cloudflare": "2.0.0-beta.87", + "@cloudflare/workers-types": "5.20261118.1", "@effect/platform-node": "4.1.7", "@effect/sql-d1": "4.1.7", "@effect/tsgo": "0.73.2", @@ -125,6 +125,7 @@ }, "peerDependencies": { "@alchemy.run/cloudflare": "*", + "@cloudflare/workers-types": "^5.20261118.1", "rolldown": "^1.2.16" }, "peerDependenciesMeta": { diff --git a/scripts/check-consumer.mjs b/scripts/check-consumer.mjs index f1b1c93..4dd5dc5 100644 --- a/scripts/check-consumer.mjs +++ b/scripts/check-consumer.mjs @@ -18,6 +18,15 @@ try { [resolve(import.meta.dirname, "../node_modules/typescript/bin/tsc"), "--project", "tsconfig.json"], { cwd: consumer, stdio: "inherit" }, ) + execFileSync( + process.execPath, + [ + resolve(import.meta.dirname, "../node_modules/typescript/bin/tsc"), + "--project", + "tsconfig.imported-state.json", + ], + { cwd: consumer, stdio: "inherit" }, + ) execFileSync(process.execPath, ["verify.mjs"], { cwd: consumer, stdio: "inherit" }) } finally { rmSync(consumer, { force: true, recursive: true }) diff --git a/test/standalone/imported-state.mts b/test/standalone/imported-state.mts new file mode 100644 index 0000000..1f09ae2 --- /dev/null +++ b/test/standalone/imported-state.mts @@ -0,0 +1,4 @@ +import type { DurableObjectState } from "@cloudflare/workers-types" +import type { HarnessSessionOptions } from "@checkfu/harnesses" + +export const sessionState = (state: DurableObjectState): HarnessSessionOptions["state"] => state diff --git a/test/standalone/package.json b/test/standalone/package.json index a9935e6..3b2f031 100644 --- a/test/standalone/package.json +++ b/test/standalone/package.json @@ -3,7 +3,7 @@ "type": "module", "dependencies": { "@alchemy.run/cloudflare-runtime": "2.0.0-beta.87", - "@cloudflare/workers-types": "5.20261118.1", + "@cloudflare/workers-types": "5.20261203.1", "@effect/platform-node": "4.1.7", "effect": "4.1.7", "miniflare": "5.20261117.0-beta", diff --git a/test/standalone/tsconfig.imported-state.json b/test/standalone/tsconfig.imported-state.json new file mode 100644 index 0000000..a44c9b2 --- /dev/null +++ b/test/standalone/tsconfig.imported-state.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": [] + }, + "files": ["imported-state.mts"] +} From aa9779525c5f086a845406cddd9422f3946f87af Mon Sep 17 00:00:00 2001 From: Andrew Lee <5784515+andyrewlee@users.noreply.github.com> Date: Sat, 5 Dec 2026 04:46:10 -0800 Subject: [PATCH 2/2] Keep the installed fixture outside the source typecheck --- scripts/check-consumer.mjs | 18 ++++-------------- test/standalone/imported-state.mjs | 5 +++++ test/standalone/imported-state.mts | 4 ---- test/standalone/tsconfig.imported-state.json | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) create mode 100644 test/standalone/imported-state.mjs delete mode 100644 test/standalone/imported-state.mts diff --git a/scripts/check-consumer.mjs b/scripts/check-consumer.mjs index 4dd5dc5..7e8f1e7 100644 --- a/scripts/check-consumer.mjs +++ b/scripts/check-consumer.mjs @@ -13,20 +13,10 @@ try { ["install", "--ignore-scripts", "--no-audit", "--no-fund", spec.endsWith(".tgz") ? resolve(spec) : spec], { cwd: consumer, stdio: "inherit" }, ) - execFileSync( - process.execPath, - [resolve(import.meta.dirname, "../node_modules/typescript/bin/tsc"), "--project", "tsconfig.json"], - { cwd: consumer, stdio: "inherit" }, - ) - execFileSync( - process.execPath, - [ - resolve(import.meta.dirname, "../node_modules/typescript/bin/tsc"), - "--project", - "tsconfig.imported-state.json", - ], - { cwd: consumer, stdio: "inherit" }, - ) + const tsc = resolve(import.meta.dirname, "../node_modules/typescript/bin/tsc") + for (const project of ["tsconfig.json", "tsconfig.imported-state.json"]) { + execFileSync(process.execPath, [tsc, "--project", project], { cwd: consumer, stdio: "inherit" }) + } execFileSync(process.execPath, ["verify.mjs"], { cwd: consumer, stdio: "inherit" }) } finally { rmSync(consumer, { force: true, recursive: true }) diff --git a/test/standalone/imported-state.mjs b/test/standalone/imported-state.mjs new file mode 100644 index 0000000..2d15d55 --- /dev/null +++ b/test/standalone/imported-state.mjs @@ -0,0 +1,5 @@ +/** + * @param {import("@cloudflare/workers-types").DurableObjectState} state + * @returns {import("@checkfu/harnesses").HarnessSessionOptions["state"]} + */ +export const sessionState = (state) => state diff --git a/test/standalone/imported-state.mts b/test/standalone/imported-state.mts deleted file mode 100644 index 1f09ae2..0000000 --- a/test/standalone/imported-state.mts +++ /dev/null @@ -1,4 +0,0 @@ -import type { DurableObjectState } from "@cloudflare/workers-types" -import type { HarnessSessionOptions } from "@checkfu/harnesses" - -export const sessionState = (state: DurableObjectState): HarnessSessionOptions["state"] => state diff --git a/test/standalone/tsconfig.imported-state.json b/test/standalone/tsconfig.imported-state.json index a44c9b2..e9ad7d3 100644 --- a/test/standalone/tsconfig.imported-state.json +++ b/test/standalone/tsconfig.imported-state.json @@ -3,5 +3,5 @@ "compilerOptions": { "types": [] }, - "files": ["imported-state.mts"] + "files": ["imported-state.mjs"] }