Browse Source

Ensure that the default es2015 libraries include dom, webworker, and scripthost

Orta Therox 5 years ago
parent
commit
4fefe8993f
2 changed files with 11 additions and 8 deletions
  1. 4 1
      src/lib/lib.ts
  2. 7 7
      src/tsWorker.ts

+ 4 - 1
src/lib/lib.ts

@@ -31,4 +31,7 @@ export const lib_es5_dts: string = "/*! ****************************************
 
 
 export const lib_es2015_dts: string = "/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved. \nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0  \n \nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, \nMERCHANTABLITY OR NON-INFRINGEMENT. \n \nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n\n\n/// <reference no-default-lib=\"true\"/>\n\n" + lib_es5_dts + "" + lib_es2015_core_dts + "" + lib_es2015_collection_dts + "" + lib_es2015_generator_dts + "" + lib_es2015_promise_dts + "" + lib_es2015_iterable_dts + "" + lib_es2015_proxy_dts + "" + lib_es2015_reflect_dts + "" + lib_es2015_symbol_dts + "" + lib_es2015_symbol_wellknown_dts + "";
 export const lib_es2015_dts: string = "/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved. \nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0  \n \nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, \nMERCHANTABLITY OR NON-INFRINGEMENT. \n \nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n\n\n/// <reference no-default-lib=\"true\"/>\n\n" + lib_es5_dts + "" + lib_es2015_core_dts + "" + lib_es2015_collection_dts + "" + lib_es2015_generator_dts + "" + lib_es2015_promise_dts + "" + lib_es2015_iterable_dts + "" + lib_es2015_proxy_dts + "" + lib_es2015_reflect_dts + "" + lib_es2015_symbol_dts + "" + lib_es2015_symbol_wellknown_dts + "";
 
 
-export const lib_dts: string = "/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved. \nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0  \n \nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, \nMERCHANTABLITY OR NON-INFRINGEMENT. \n \nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n\n\n/// <reference no-default-lib=\"true\"/>\n\n" + lib_es5_dts + "" + lib_dom_dts + "" + lib_webworker_importscripts_dts + "" + lib_scripthost_dts + "";
+export const lib_es5_bundled_dts: string = "/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved. \nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0  \n \nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, \nMERCHANTABLITY OR NON-INFRINGEMENT. \n \nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n\n\n/// <reference no-default-lib=\"true\"/>\n\n" + lib_es5_dts + "" + lib_dom_dts + "" + lib_webworker_importscripts_dts + "" + lib_scripthost_dts + "";
+
+/** This is the DTS which is used by default in monaco-typescript */
+export const lib_es2015_bundled_dts = lib_es2015_dts + "" + lib_dom_dts + "" + lib_webworker_importscripts_dts + "" + lib_scripthost_dts + ""

+ 7 - 7
src/tsWorker.ts

@@ -5,19 +5,19 @@
 'use strict';
 'use strict';
 
 
 import * as ts from './lib/typescriptServices';
 import * as ts from './lib/typescriptServices';
-import { lib_dts, lib_es2015_dts } from './lib/lib';
+import { lib_es5_dts, lib_es2015_bundled_dts } from './lib/lib';
 import { IExtraLibs } from './monaco.contribution';
 import { IExtraLibs } from './monaco.contribution';
 
 
 import IWorkerContext = monaco.worker.IWorkerContext;
 import IWorkerContext = monaco.worker.IWorkerContext;
 
 
-const DEFAULT_LIB = {
+const DEFAULT_ES5_LIB = {
 	NAME: 'defaultLib:lib.d.ts',
 	NAME: 'defaultLib:lib.d.ts',
-	CONTENTS: lib_dts
+	CONTENTS: lib_es5_dts
 };
 };
 
 
 const ES2015_LIB = {
 const ES2015_LIB = {
 	NAME: 'defaultLib:lib.es2015.d.ts',
 	NAME: 'defaultLib:lib.es2015.d.ts',
-	CONTENTS: lib_es2015_dts
+	CONTENTS: lib_es2015_bundled_dts
 };
 };
 
 
 export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.languages.typescript.TypeScriptWorker {
 export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.languages.typescript.TypeScriptWorker {
@@ -84,8 +84,8 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language
 			// extra lib
 			// extra lib
 			text = this._extraLibs[fileName].content;
 			text = this._extraLibs[fileName].content;
 
 
-		} else if (fileName === DEFAULT_LIB.NAME) {
-			text = DEFAULT_LIB.CONTENTS;
+		} else if (fileName === DEFAULT_ES5_LIB.NAME) {
+			text = DEFAULT_ES5_LIB.CONTENTS;
 		} else if (fileName === ES2015_LIB.NAME) {
 		} else if (fileName === ES2015_LIB.NAME) {
 			text = ES2015_LIB.CONTENTS;
 			text = ES2015_LIB.CONTENTS;
 		} else {
 		} else {
@@ -127,7 +127,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language
 
 
 	getDefaultLibFileName(options: ts.CompilerOptions): string {
 	getDefaultLibFileName(options: ts.CompilerOptions): string {
 		// TODO@joh support lib.es7.d.ts
 		// TODO@joh support lib.es7.d.ts
-		return (options.target || ts.ScriptTarget.ES2015) <= ts.ScriptTarget.ES2015 ? DEFAULT_LIB.NAME : ES2015_LIB.NAME;
+		return (options.target || ts.ScriptTarget.ES2015) < ts.ScriptTarget.ES2015 ? DEFAULT_ES5_LIB.NAME : ES2015_LIB.NAME;
 	}
 	}
 
 
 	isDefaultLibFileName(fileName: string): boolean {
 	isDefaultLibFileName(fileName: string): boolean {