Browse Source

Share: fix types

Frank 9 months ago
parent
commit
72d10a0823
2 changed files with 5 additions and 11 deletions
  1. 3 10
      app/packages/function/src/api.ts
  2. 2 1
      app/packages/function/tsconfig.json

+ 3 - 10
app/packages/function/src/api.ts

@@ -1,20 +1,16 @@
 import { DurableObject } from "cloudflare:workers"
-import {
-  DurableObjectNamespace,
-  ExecutionContext,
-} from "@cloudflare/workers-types"
 import { createHash } from "node:crypto"
 import path from "node:path"
 import { Resource } from "sst"
 
 type Bindings = {
-  SYNC_SERVER: DurableObjectNamespace<WebSocketHibernationServer>
+  SYNC_SERVER: DurableObjectNamespace
 }
 
 export class SyncServer extends DurableObject {
   private files: Map<string, string> = new Map()
 
-  constructor(ctx, env) {
+  constructor(ctx: DurableObjectState, env: Bindings) {
     super(ctx, env)
     this.ctx.blockConcurrencyWhile(async () => {
       this.files = await this.ctx.storage.list()
@@ -38,10 +34,7 @@ export class SyncServer extends DurableObject {
     })
   }
 
-  async webSocketMessage(ws, message) {
-    if (message === "load_history") {
-    }
-  }
+  async webSocketMessage(ws, message) {}
 
   async webSocketClose(ws, code, reason, wasClean) {
     ws.close(code, "Durable Object is closing WebSocket")

+ 2 - 1
app/packages/function/tsconfig.json

@@ -3,6 +3,7 @@
   "extends": "@tsconfig/node22/tsconfig.json",
   "compilerOptions": {
     "module": "ESNext",
-    "moduleResolution": "bundler"
+    "moduleResolution": "bundler",
+    "types": ["@cloudflare/workers-types", "node"]
   }
 }