From bfb3cd7a5c55dbf59eacb7d93e88f38632e47260 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 14 May 2018 01:19:23 -0400 Subject: [PATCH] use tsc for type checking --- Makefile | 1 + main.ts | 5 ++--- v8worker2.d.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 v8worker2.d.ts diff --git a/Makefile b/Makefile index 5cd8b9c150..6ccc4781d5 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ msg.pb.d.ts: msg.pb.js node_modules ./node_modules/.bin/pbts -o msg.pb.d.ts msg.pb.js dist/main.js: main.ts msg.pb.js msg.pb.d.ts node_modules + ./node_modules/.bin/tsc --noEmit # Only for type checking. ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts node_modules: diff --git a/main.ts b/main.ts index 9071c2fcd7..44519489ab 100644 --- a/main.ts +++ b/main.ts @@ -1,9 +1,8 @@ -import * as ts from "typescript"; +//import * as ts from "typescript"; import { main as pb } from "./msg.pb" -V8Worker2.recv((ab: ArrayBuffer) { +V8Worker2.recv((ab: ArrayBuffer) => { let msg = pb.Msg.decode(new Uint8Array(ab)); - V8Worker2.print("Got array buffer", ab.byteLength); V8Worker2.print("msg.argv", msg.argv); }); diff --git a/v8worker2.d.ts b/v8worker2.d.ts new file mode 100644 index 0000000000..9ace56ff7a --- /dev/null +++ b/v8worker2.d.ts @@ -0,0 +1,6 @@ +declare namespace V8Worker2 { + function print(...args: any[]): void; + type RecvCallback = (ab: ArrayBuffer) => void; + function recv(cb: RecvCallback): void; + function send(ab: ArrayBuffer): null | ArrayBuffer; +}