diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/assets.ts | 33 | ||||
-rw-r--r-- | js/compiler.ts | 8 | ||||
-rw-r--r-- | js/compiler_test.ts | 4 | ||||
-rw-r--r-- | js/deno.ts | 1 | ||||
-rw-r--r-- | js/globals.ts | 10 | ||||
-rw-r--r-- | js/lib.globals.d.ts | 2 | ||||
-rw-r--r-- | js/os.ts | 6 | ||||
-rw-r--r-- | js/tsconfig.generated.json | 1 | ||||
-rw-r--r-- | js/types.ts (renamed from js/types.d.ts) | 8 |
9 files changed, 32 insertions, 41 deletions
diff --git a/js/assets.ts b/js/assets.ts index 89b3e2645..e5ec507f7 100644 --- a/js/assets.ts +++ b/js/assets.ts @@ -1,21 +1,13 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. // tslint:disable-next-line:no-reference -/// <reference path="plugins.d.ts" /> +/// <reference path="./plugins.d.ts" /> // There is a rollup plugin that will inline any module ending with `!string` // tslint:disable:max-line-length // Generated definitions -import compilerDts from "gen/js/compiler.d.ts!string"; -import consoleDts from "gen/js/console.d.ts!string"; -import denoDts from "gen/js/deno.d.ts!string"; -import libdenoDts from "gen/js/libdeno.d.ts!string"; -import globalsDts from "gen/js/globals.d.ts!string"; -import osDts from "gen/js/os.d.ts!string"; -import fetchDts from "gen/js/fetch.d.ts!string"; -import timersDts from "gen/js/timers.d.ts!string"; -import utilDts from "gen/js/util.d.ts!string"; +import globalsDts from "gen/types/globals.d.ts!string"; // Static libraries import libEs2015Dts from "/third_party/node_modules/typescript/lib/lib.es2015.d.ts!string"; @@ -49,24 +41,16 @@ import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esn import libGlobalsDts from "/js/lib.globals.d.ts!string"; // Static definitions -import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string"; -import typesDts from "/js/types.d.ts!string"; import fetchTypesDts from "/js/fetch_types.d.ts!string"; +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 // prettier-ignore export const assetSourceCode: { [key: string]: string } = { // Generated definitions - "compiler.d.ts": compilerDts, - "console.d.ts": consoleDts, - "deno.d.ts": denoDts, - "libdeno.d.ts": libdenoDts, "globals.d.ts": globalsDts, - "os.d.ts": osDts, - "fetch.d.ts": fetchDts, - "fetch_types.d.ts": fetchTypesDts, - "timers.d.ts": timersDts, - "util.d.ts": utilDts, // Static libraries "lib.es2015.collection.d.ts": libEs2015CollectionDts, @@ -100,9 +84,8 @@ export const assetSourceCode: { [key: string]: string } = { "lib.globals.d.ts": libGlobalsDts, // Static definitions + "fetch-types.d.ts": fetchTypesDts, + "flatbuffers.d.ts": flatbuffersDts, + "text-encoding.d.ts": textEncodingDts, "typescript.d.ts": typescriptDts, - "types.d.ts": typesDts, - - // TODO Remove. - "msg_generated.d.ts": "", }; diff --git a/js/compiler.ts b/js/compiler.ts index 2e8c525b8..28fe8be8f 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -1,4 +1,5 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. +/// <amd-module name="compiler"/> import * as ts from "typescript"; import { assetSourceCode } from "./assets"; import * as deno from "./deno"; @@ -669,10 +670,9 @@ export class DenoCompiler implements ts.LanguageServiceHost { this._log("resolveModuleNames()", { moduleNames, containingFile }); return moduleNames.map(name => { let resolvedFileName; - if (name === "deno") { - resolvedFileName = this.resolveModuleName("deno.d.ts", ASSETS); - } else if (name === "compiler") { - resolvedFileName = this.resolveModuleName("compiler.d.ts", ASSETS); + if (name === "deno" || name === "compiler") { + // builtin modules are part of `globals.d.ts` + resolvedFileName = this.resolveModuleName("globals.d.ts", 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 2fb67ab3b..18c2d16cc 100644 --- a/js/compiler_test.ts +++ b/js/compiler_test.ts @@ -474,7 +474,7 @@ test(function compilerFileExists() { "/root/project" ); assert(compilerInstance.fileExists(moduleMetaData.fileName)); - assert(compilerInstance.fileExists("$asset$/compiler.d.ts")); + assert(compilerInstance.fileExists("$asset$/globals.d.ts")); assertEqual( compilerInstance.fileExists("/root/project/unknown-module.ts"), false @@ -493,7 +493,7 @@ test(function compilerResolveModuleNames() { ["/root/project/foo/bar.ts", false], ["/root/project/foo/baz.ts", false], ["$asset$/lib.globals.d.ts", true], - ["$asset$/deno.d.ts", true] + ["$asset$/globals.d.ts", true] ]; for (let i = 0; i < results.length; i++) { const result = results[i]; diff --git a/js/deno.ts b/js/deno.ts index c9611d116..21766401b 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -1,5 +1,6 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. // Public deno module. +/// <amd-module name="deno"/> export { env, exit, diff --git a/js/globals.ts b/js/globals.ts index 0364aaf98..b90aa46eb 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -2,7 +2,7 @@ import { Console } from "./console"; import * as timers from "./timers"; -import { TextDecoder, TextEncoder } from "./text_encoding"; +import * as textEncoding from "./text_encoding"; import * as fetch_ from "./fetch"; import { libdeno } from "./libdeno"; import { globalEval } from "./global-eval"; @@ -24,8 +24,8 @@ declare global { const fetch: typeof fetch_.fetch; // tslint:disable:variable-name - let TextEncoder: TextEncoder; - let TextDecoder: TextDecoder; + let TextEncoder: typeof textEncoding.TextEncoder; + let TextDecoder: typeof textEncoding.TextDecoder; // tslint:enable:variable-name } @@ -41,7 +41,7 @@ window.clearTimeout = timers.clearTimer; window.clearInterval = timers.clearTimer; window.console = new Console(libdeno.print); -window.TextEncoder = TextEncoder; -window.TextDecoder = TextDecoder; +window.TextEncoder = textEncoding.TextEncoder; +window.TextDecoder = textEncoding.TextDecoder; window.fetch = fetch_.fetch; diff --git a/js/lib.globals.d.ts b/js/lib.globals.d.ts index a1526c573..5243e4b5d 100644 --- a/js/lib.globals.d.ts +++ b/js/lib.globals.d.ts @@ -2,4 +2,4 @@ // This file contains the default TypeScript libraries for the deno runtime. /// <reference no-default-lib="true"/> /// <reference lib="esnext" /> -import "gen/js/globals"; +/// <reference path="globals.d.ts"/> @@ -128,8 +128,8 @@ export function readFileSync(filename: string): Uint8Array { return new Uint8Array(dataArray!); } -function createEnv(_msg: fbs.EnvironRes): { [index:string]: string } { - const env: { [index:string]: string } = {}; +function createEnv(_msg: fbs.EnvironRes): { [index: string]: string } { + const env: { [index: string]: string } = {}; for (let i = 0; i < _msg.mapLength(); i++) { const item = _msg.map(i)!; @@ -169,7 +169,7 @@ function setEnv(key: string, value: string): void { * const newEnv = deno.env(); * console.log(env.TEST_VAR == newEnv.TEST_VAR); */ -export function env(): { [index:string]: string } { +export function env(): { [index: string]: string } { /* Ideally we could write const res = send({ command: fbs.Command.ENV, diff --git a/js/tsconfig.generated.json b/js/tsconfig.generated.json index d3cacd73e..8a8269d5b 100644 --- a/js/tsconfig.generated.json +++ b/js/tsconfig.generated.json @@ -7,6 +7,7 @@ "compilerOptions": { "declaration": true, "emitDeclarationOnly": true, + "module": "amd", "stripInternal": true }, "files": [ diff --git a/js/types.d.ts b/js/types.ts index 110873c6b..7af0a5201 100644 --- a/js/types.d.ts +++ b/js/types.ts @@ -8,6 +8,7 @@ export interface ModuleInfo { outputCode: string | null; } +// tslint:disable:max-line-length // Following definitions adapted from: // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts // Type definitions for Node.js 10.3.x @@ -36,11 +37,13 @@ export interface ModuleInfo { // Alexander T. <https://github.com/a-tarasyuk> // Lishude <https://github.com/islishude> // Andrew Makarov <https://github.com/r3nya> +// tslint:enable:max-line-length export interface CallSite { /** * Value of "this" */ + // tslint:disable-next-line:no-any getThis(): any; /** @@ -133,13 +136,16 @@ declare global { // Declare "static" methods in Error interface ErrorConstructor { /** Create .stack property on a target object */ - captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + captureStackTrace(targetObject: object, constructorOpt?: Function): void; + // tslint:disable:max-line-length /** * Optional override for formatting stack traces * * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces */ + // tslint:enable:max-line-length + // tslint:disable-next-line:no-any prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any; stackTraceLimit: number; |