Browse Source

fix(core): tolerate minimal FSWatcher typings (#35264)

Kit Langton 1 tháng trước cách đây
mục cha
commit
e2faeb84e5
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      packages/core/src/filesystem/watcher.ts

+ 5 - 3
packages/core/src/filesystem/watcher.ts

@@ -89,9 +89,11 @@ const layer = Layer.effect(
                     type: "update",
                   } satisfies Update)
                 })
-                subscription.on("error", (error) =>
-                  Effect.runFork(Effect.logError("watcher callback failed", { path: target, error })),
-                )
+                if ("on" in subscription && typeof subscription.on === "function") {
+                  subscription.on("error", (error: unknown) =>
+                    Effect.runFork(Effect.logError("watcher callback failed", { path: target, error })),
+                  )
+                }
                 return { unsubscribe: () => Promise.resolve(subscription.close()) }
               })
             : subscribeDirectory(native, backend, directory, ignore, pubsub)