X Tutup
Skip to content

Commit a175bfe

Browse files
fix Firefox support
1 parent 938edc6 commit a175bfe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

game/src/worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { GameBase } from "./game-base";
22
import { calculateBestMove } from "./ai/process";
33
import { WorkerOutgoingMessage } from "./types-worker";
44

5+
// see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage
6+
// we wouldn't need this workaround if we could have a separate typescript config just for
7+
// the worker.
8+
declare function postMessage(messagse: any);
9+
510
onmessage = function(this: Window, ev: MessageEvent) {
611
let data = ev.data;
712
if (data.task === "processAI") {
@@ -13,6 +18,6 @@ onmessage = function(this: Window, ev: MessageEvent) {
1318
task: "processAI",
1419
result,
1520
};
16-
this.postMessage(msg, null);
21+
postMessage(msg);
1722
}
1823
};

0 commit comments

Comments
 (0)
X Tutup