1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -05:00

Remove lib.globals.d.ts

This commit is contained in:
Kitson Kelly 2018-09-01 10:47:13 -07:00 committed by Ryan Dahl
parent f83aee02e6
commit b3dac82887
6 changed files with 15 additions and 19 deletions

View file

@ -227,7 +227,6 @@ run_node("bundle") {
"js/fetch.ts", "js/fetch.ts",
"js/fetch_types.d.ts", "js/fetch_types.d.ts",
"js/globals.ts", "js/globals.ts",
"js/lib.globals.d.ts",
"js/main.ts", "js/main.ts",
"js/os.ts", "js/os.ts",
"js/plugins.d.ts", "js/plugins.d.ts",

View file

@ -6,7 +6,7 @@
// There is a rollup plugin that will inline any module ending with `!string` // There is a rollup plugin that will inline any module ending with `!string`
// tslint:disable:max-line-length // tslint:disable:max-line-length
// Generated definitions // Generated default library
import globalsDts from "gen/types/globals.d.ts!string"; import globalsDts from "gen/types/globals.d.ts!string";
// Static libraries // Static libraries
@ -38,7 +38,6 @@ import libEsnextAsynciterablesDts from "/third_party/node_modules/typescript/lib
import libEsnextDts from "/third_party/node_modules/typescript/lib/lib.esnext.d.ts!string"; import libEsnextDts from "/third_party/node_modules/typescript/lib/lib.esnext.d.ts!string";
import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnext.intl.d.ts!string"; import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnext.intl.d.ts!string";
import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string"; import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string";
import libGlobalsDts from "/js/lib.globals.d.ts!string";
// Static definitions // Static definitions
import fetchTypesDts from "/js/fetch_types.d.ts!string"; import fetchTypesDts from "/js/fetch_types.d.ts!string";
@ -49,7 +48,7 @@ import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d
// prettier-ignore // prettier-ignore
export const assetSourceCode: { [key: string]: string } = { export const assetSourceCode: { [key: string]: string } = {
// Generated definitions // Generated library
"globals.d.ts": globalsDts, "globals.d.ts": globalsDts,
// Static libraries // Static libraries
@ -81,7 +80,6 @@ export const assetSourceCode: { [key: string]: string } = {
"lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts, "lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts,
"lib.esnext.intl.d.ts": libEsnextIntlDts, "lib.esnext.intl.d.ts": libEsnextIntlDts,
"lib.esnext.symbol.d.ts": libEsnextSymbolDts, "lib.esnext.symbol.d.ts": libEsnextSymbolDts,
"lib.globals.d.ts": libGlobalsDts,
// Static definitions // Static definitions
"fetch-types.d.ts": fetchTypesDts, "fetch-types.d.ts": fetchTypesDts,

View file

@ -641,7 +641,7 @@ export class DenoCompiler implements ts.LanguageServiceHost {
getDefaultLibFileName(): string { getDefaultLibFileName(): string {
this._log("getDefaultLibFileName()"); this._log("getDefaultLibFileName()");
const moduleSpecifier = "lib.globals.d.ts"; const moduleSpecifier = "globals.d.ts";
const moduleMetaData = this.resolveModule(moduleSpecifier, ASSETS); const moduleMetaData = this.resolveModule(moduleSpecifier, ASSETS);
return moduleMetaData.fileName; return moduleMetaData.fileName;
} }

View file

@ -445,10 +445,7 @@ test(function compilerGetCurrentDirectory() {
test(function compilerGetDefaultLibFileName() { test(function compilerGetDefaultLibFileName() {
setup(); setup();
assertEqual( assertEqual(compilerInstance.getDefaultLibFileName(), "$asset$/globals.d.ts");
compilerInstance.getDefaultLibFileName(),
"$asset$/lib.globals.d.ts"
);
teardown(); teardown();
}); });
@ -485,14 +482,13 @@ test(function compilerFileExists() {
test(function compilerResolveModuleNames() { test(function compilerResolveModuleNames() {
setup(); setup();
const results = compilerInstance.resolveModuleNames( const results = compilerInstance.resolveModuleNames(
["foo/bar.ts", "foo/baz.ts", "$asset$/lib.globals.d.ts", "deno"], ["foo/bar.ts", "foo/baz.ts", "deno"],
"/root/project" "/root/project"
); );
assertEqual(results.length, 4); assertEqual(results.length, 3);
const fixtures: Array<[string, boolean]> = [ const fixtures: Array<[string, boolean]> = [
["/root/project/foo/bar.ts", false], ["/root/project/foo/bar.ts", false],
["/root/project/foo/baz.ts", false], ["/root/project/foo/baz.ts", false],
["$asset$/lib.globals.d.ts", true],
["$asset$/globals.d.ts", true] ["$asset$/globals.d.ts", true]
]; ];
for (let i = 0; i < results.length; i++) { for (let i = 0; i < results.length; i++) {

5
js/lib.globals.d.ts vendored
View file

@ -1,5 +0,0 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
// This file contains the default TypeScript libraries for the deno runtime.
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />
/// <reference path="globals.d.ts"/>

View file

@ -24,6 +24,12 @@ const tsconfigOverride = {
} }
}; };
// this is a preamble for the `globals.d.ts` file to allow it to be the default
// lib for deno.
const libPreamble = `/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />
`;
// this is a rollup plugin which will look for imports ending with `!string` and resolve // this is a rollup plugin which will look for imports ending with `!string` and resolve
// them with a module that will inline the contents of the file as a string. Needed to // them with a module that will inline the contents of the file as a string. Needed to
// support `js/assets.ts`. // support `js/assets.ts`.
@ -62,7 +68,9 @@ function strings({ include, exclude } = {}) {
transform(code, id) { transform(code, id) {
if (filter(id)) { if (filter(id)) {
return { return {
code: `export default ${JSON.stringify(code)};`, code: `export default ${JSON.stringify(
id.endsWith("globals.d.ts") ? libPreamble + code : code
)};`,
map: { mappings: "" } map: { mappings: "" }
}; };
} }