No matching export in for import "WebSocketPair" even though I see the type.

I have a weird error where when I run wrangler it doesn't see the export of the WebSocketPair type even though I see the exported type in the file the log is referencing.. Also, other types work like "DurableObjectState" Here is where is it messing up:
import { DurableObjectState, WebSocketPair } from "@cloudflare/workers-types";
import { DurableObjectState, WebSocketPair } from "@cloudflare/workers-types";
Here is my package.json:
{
"name": "@croak/hono-crud",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"deploy": "wrangler deploy --minify",
"dev": "wrangler dev --port 8080 --remote",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"typecheck": "tsc --noEmit",
"clean": "rm -rf .turbo .wrangler node_modules",
"localtunnel": "npx lt --port 8080"
},
"dependencies": {
"@acme/shared-functions": "*",
"@clerk/backend": "^0.30.*",
"@cloudflare/ai": "^1.0.53",
"@hono/clerk-auth": "^1.0.0",
"@hono/trpc-server": "*",
"@paralleldrive/cuid2": "^2.2.2",
"@trpc/server": "next",
"cors": "^2.8.5",
"drizzle-zod": "^0.5.1",
"hono": "^3.11.7",
"superjson": "1.9.1",
"svix": "^1.16.0",
"typescript": "^5.3.3",
"zod": "^3.22.4"
},
"devDependencies": {
"@acme/db": "*",
"@cloudflare/workers-types": "^4.20231121.0",
"eslint": "^8.56.0",
"localtunnel": "^2.0.2",
"prettier": "^3.1.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"wrangler": "^3.22.1"
}
}
{
"name": "@croak/hono-crud",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"deploy": "wrangler deploy --minify",
"dev": "wrangler dev --port 8080 --remote",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"typecheck": "tsc --noEmit",
"clean": "rm -rf .turbo .wrangler node_modules",
"localtunnel": "npx lt --port 8080"
},
"dependencies": {
"@acme/shared-functions": "*",
"@clerk/backend": "^0.30.*",
"@cloudflare/ai": "^1.0.53",
"@hono/clerk-auth": "^1.0.0",
"@hono/trpc-server": "*",
"@paralleldrive/cuid2": "^2.2.2",
"@trpc/server": "next",
"cors": "^2.8.5",
"drizzle-zod": "^0.5.1",
"hono": "^3.11.7",
"superjson": "1.9.1",
"svix": "^1.16.0",
"typescript": "^5.3.3",
"zod": "^3.22.4"
},
"devDependencies": {
"@acme/db": "*",
"@cloudflare/workers-types": "^4.20231121.0",
"eslint": "^8.56.0",
"localtunnel": "^2.0.2",
"prettier": "^3.1.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"wrangler": "^3.22.1"
}
}
1 Reply
Ben
BenOP9mo ago
For anyone that gets the same issue, the solution is quite simple. Instead of importing the types, simply add the type to the tsconfig.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext"],
"types": ["@cloudflare/workers-types"]
}
}
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext"],
"types": ["@cloudflare/workers-types"]
}
}
Want results from more Discord servers?
Add your server