diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/assets.ts | 6 | ||||
-rw-r--r-- | js/compiler.ts | 7 | ||||
-rw-r--r-- | js/compiler_test.ts | 9 | ||||
-rw-r--r-- | js/globals.ts | 61 | ||||
-rw-r--r-- | js/testing/testing.ts | 2 | ||||
-rw-r--r-- | js/tsconfig.declarations.json | 19 |
6 files changed, 27 insertions, 77 deletions
diff --git a/js/assets.ts b/js/assets.ts index c860555c4..481c48239 100644 --- a/js/assets.ts +++ b/js/assets.ts @@ -7,7 +7,7 @@ // tslint:disable:max-line-length // Generated default library -import globalsDts from "gen/types/globals.d.ts!string"; +import libDts from "gen/lib/lib.deno_runtime.d.ts!string"; // Static libraries import libEs2015Dts from "/third_party/node_modules/typescript/lib/lib.es2015.d.ts!string"; @@ -40,7 +40,6 @@ import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnex import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string"; // Static definitions -import flatbuffersDts from "/third_party/node_modules/@types/flatbuffers/index.d.ts!string"; import textEncodingDts from "/third_party/node_modules/@types/text-encoding/index.d.ts!string"; import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string"; // tslint:enable:max-line-length @@ -48,7 +47,7 @@ import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d // @internal export const assetSourceCode: { [key: string]: string } = { // Generated library - "globals.d.ts": globalsDts, + "lib.deno_runtime.d.ts": libDts, // Static libraries "lib.es2015.collection.d.ts": libEs2015CollectionDts, @@ -81,7 +80,6 @@ export const assetSourceCode: { [key: string]: string } = { "lib.esnext.symbol.d.ts": libEsnextSymbolDts, // Static definitions - "flatbuffers.d.ts": flatbuffersDts, "text-encoding.d.ts": textEncodingDts, "typescript.d.ts": typescriptDts }; diff --git a/js/compiler.ts b/js/compiler.ts index 7b577a8b9..c398f181d 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -13,6 +13,7 @@ import * as sourceMaps from "./v8_source_maps"; const EOL = "\n"; const ASSETS = "$asset$"; +const LIB_RUNTIME = "lib.deno_runtime.d.ts"; // tslint:disable:no-any type AmdCallback = (...args: any[]) => void; @@ -619,7 +620,7 @@ export class DenoCompiler getDefaultLibFileName(): string { this._log("getDefaultLibFileName()"); - const moduleSpecifier = "globals.d.ts"; + const moduleSpecifier = LIB_RUNTIME; const moduleMetaData = this.resolveModule(moduleSpecifier, ASSETS); return moduleMetaData.fileName; } @@ -649,8 +650,8 @@ export class DenoCompiler return moduleNames.map(name => { let resolvedFileName; if (name === "deno") { - // builtin modules are part of `globals.d.ts` - resolvedFileName = this._resolveModuleName("globals.d.ts", ASSETS); + // builtin modules are part of the runtime lib + resolvedFileName = this._resolveModuleName(LIB_RUNTIME, ASSETS); } else if (name === "typescript") { resolvedFileName = this._resolveModuleName("typescript.d.ts", ASSETS); } else { diff --git a/js/compiler_test.ts b/js/compiler_test.ts index dcb8c1285..f05a96e52 100644 --- a/js/compiler_test.ts +++ b/js/compiler_test.ts @@ -546,7 +546,10 @@ test(function compilerGetCurrentDirectory() { test(function compilerGetDefaultLibFileName() { setup(); - assertEqual(compilerInstance.getDefaultLibFileName(), "$asset$/globals.d.ts"); + assertEqual( + compilerInstance.getDefaultLibFileName(), + "$asset$/lib.deno_runtime.d.ts" + ); teardown(); }); @@ -572,7 +575,7 @@ test(function compilerFileExists() { "/root/project" ); assert(compilerInstance.fileExists(moduleMetaData.fileName)); - assert(compilerInstance.fileExists("$asset$/globals.d.ts")); + assert(compilerInstance.fileExists("$asset$/lib.deno_runtime.d.ts")); assertEqual( compilerInstance.fileExists("/root/project/unknown-module.ts"), false @@ -590,7 +593,7 @@ test(function compilerResolveModuleNames() { const fixtures: Array<[string, boolean]> = [ ["/root/project/foo/bar.ts", false], ["/root/project/foo/baz.ts", false], - ["$asset$/globals.d.ts", true] + ["$asset$/lib.deno_runtime.d.ts", true] ]; for (let i = 0; i < results.length; i++) { const result = results[i]; diff --git a/js/globals.ts b/js/globals.ts index 2e6b24305..11a172633 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -1,55 +1,22 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { Console } from "./console"; -import * as timers from "./timers"; -import * as textEncoding from "./text_encoding"; +import * as blob from "./blob"; +import * as console from "./console"; import * as fetch_ from "./fetch"; -import { libdeno } from "./libdeno"; import { globalEval } from "./global_eval"; -import { DenoHeaders } from "./fetch"; -import { DenoBlob } from "./blob"; - -declare global { - interface Window { - define: Readonly<unknown>; - - clearTimeout: typeof clearTimeout; - clearInterval: typeof clearInterval; - setTimeout: typeof setTimeout; - setInterval: typeof setInterval; - - console: typeof console; - window: typeof window; - - fetch: typeof fetch; - - TextEncoder: typeof TextEncoder; - TextDecoder: typeof TextDecoder; - atob: typeof atob; - btoa: typeof btoa; +import { libdeno } from "./libdeno"; +import * as textEncoding from "./text_encoding"; +import * as timers from "./timers"; - Headers: typeof Headers; - Blob: typeof Blob; - } +// During the build process, augmentations to the variable `window` in this +// file are tracked and created as part of default library that is built into +// deno, we only need to declare the enough to compile deno. - const clearTimeout: typeof timers.clearTimer; - const clearInterval: typeof timers.clearTimer; +declare global { + const console: console.Console; const setTimeout: typeof timers.setTimeout; - const setInterval: typeof timers.setInterval; - - const console: Console; - const window: Window; - - const fetch: typeof fetch_.fetch; - - // tslint:disable:variable-name + // tslint:disable-next-line:variable-name const TextEncoder: typeof textEncoding.TextEncoder; - const TextDecoder: typeof textEncoding.TextDecoder; - const atob: typeof textEncoding.atob; - const btoa: typeof textEncoding.btoa; - const Headers: typeof DenoHeaders; - const Blob: typeof DenoBlob; - // tslint:enable:variable-name } // A reference to the global object. @@ -61,7 +28,7 @@ window.setInterval = timers.setInterval; window.clearTimeout = timers.clearTimer; window.clearInterval = timers.clearTimer; -window.console = new Console(libdeno.print); +window.console = new console.Console(libdeno.print); window.TextEncoder = textEncoding.TextEncoder; window.TextDecoder = textEncoding.TextDecoder; window.atob = textEncoding.atob; @@ -69,5 +36,5 @@ window.btoa = textEncoding.btoa; window.fetch = fetch_.fetch; -window.Headers = DenoHeaders; -window.Blob = DenoBlob; +window.Headers = fetch_.DenoHeaders; +window.Blob = blob.DenoBlob; diff --git a/js/testing/testing.ts b/js/testing/testing.ts index ff91ddebc..437cb0f38 100644 --- a/js/testing/testing.ts +++ b/js/testing/testing.ts @@ -13,7 +13,7 @@ limitations under the License. */ -export { assert, assertEqual, equal } from "./util.ts"; +export { assert, assertEqual, equal } from "./util"; export type TestFunction = () => void | Promise<void>; diff --git a/js/tsconfig.declarations.json b/js/tsconfig.declarations.json deleted file mode 100644 index 6371182b6..000000000 --- a/js/tsconfig.declarations.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // This configuration file provides the tsc configuration for generating - // definitions for the runtime, which are then inlined via the `js/assets.ts` - // module into the bundle to be available for type checking at runtime - // See also gen_declarations in //BUILD.gn - "extends": "../tsconfig.json", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "module": "amd", - "removeComments": false, - "stripInternal": true - }, - "files": [ - "../node_modules/typescript/lib/lib.esnext.d.ts", - "./deno.ts", - "./globals.ts" - ] -} |