summaryrefslogtreecommitdiff
path: root/js/globals.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-08-07 13:27:31 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-08-08 04:17:46 -0700
commit817380a2d9e42b118706638fe59c592f4bba06ef (patch)
tree30bbff8221390d0d880570a29c939542c5d0ff5d /js/globals.ts
parenteda1c7b74a583a567c781fe13e63a80c2d4dcc3d (diff)
Generate declarations
Diffstat (limited to 'js/globals.ts')
-rw-r--r--js/globals.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/js/globals.ts b/js/globals.ts
index c36eaff60..82c9a24c0 100644
--- a/js/globals.ts
+++ b/js/globals.ts
@@ -1,5 +1,25 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import { Console } from "./console";
+
+declare global {
+ type MessageCallback = (msg: Uint8Array) => void;
+
+ interface Deno {
+ print(text: string): void;
+ recv(cb: MessageCallback): void;
+ send(msg: ArrayBufferView): Uint8Array | null;
+ }
+
+ interface Window {
+ console: Console;
+ }
+
+ const console: Console;
+ const deno: Readonly<Deno>;
+ const window: Window;
+}
+
// If you use the eval function indirectly, by invoking it via a reference
// other than eval, as of ECMAScript 5 it works in the global scope rather than
// the local scope. This means, for instance, that function declarations create
@@ -20,7 +40,6 @@ window["window"] = window; // Create a window object.
// window["clearTimeout"] = timer.clearTimer;
// window["clearInterval"] = timer.clearTimer;
-import { Console } from "./console";
window["console"] = new Console();
// import { fetch } from "./fetch";