diff options
Diffstat (limited to 'js/globals.ts')
-rw-r--r-- | js/globals.ts | 21 |
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"; |