瀏覽代碼

Adds backwards compatability for diagnostic chains

Orta Therox 5 年之前
父節點
當前提交
c8b92c097f

+ 4 - 4
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "monaco-typescript",
-  "version": "3.6.0",
+  "version": "3.6.2",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -52,9 +52,9 @@
       "dev": true
     },
     "typescript": {
-      "version": "3.5.1",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz",
-      "integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==",
+      "version": "3.6.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.2.tgz",
+      "integrity": "sha512-lmQ4L+J6mnu3xweP8+rOrUwzmN+MRAj7TgtJtDaXE5PMyX2kCrklhg3rvOsOIfNeAWMQWO2F1GPc1kMD2vLAfw==",
       "dev": true
     },
     "uglify-js": {

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "monaco-typescript",
-  "version": "3.6.0",
+  "version": "3.6.2",
   "description": "TypeScript and JavaScript language support for Monaco Editor",
   "scripts": {
     "compile-amd": "mcopy ./src/lib/typescriptServices-amd.js ./release/dev/lib/typescriptServices.js && tsc -p ./src/tsconfig.json",
@@ -25,7 +25,7 @@
     "monaco-languages": "^1.7.0",
     "monaco-plugin-helpers": "^1.0.2",
     "requirejs": "^2.3.6",
-    "typescript": "^3.5.1",
+    "typescript": "^3.6.2",
     "uglify-js": "^3.4.9"
   }
 }

+ 7 - 0
scripts/importTypescript.js

@@ -30,6 +30,12 @@ const TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, '../src/lib');
 		tsServices.replace(/return require\(fileNameToRequire\);/, `// MONACOCHANGE\n            return undefined;\n            // END MONACOCHANGE`)
 	);
 
+	// Make sure process.args don't get called in the browser, this
+	// should only happen in TS 2.6.2
+	const beforeProcess = `ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(process.argv));`
+	const afterProcess = `// MONACOCHANGE\n    ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify([]));\n// END MONACOCHANGE`
+	tsServices = tsServices.replace(beforeProcess, afterProcess);
+
 	var tsServices_amd = tsServices +
 		`
 // MONACOCHANGE
@@ -64,6 +70,7 @@ export = ts;
 // END MONACOCHANGE
 `;
 	fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'), dtsServices);
+
 })();
 
 function importLibs() {

+ 22 - 3
src/languageFeatures.ts

@@ -15,7 +15,7 @@ import Thenable = monaco.Thenable;
 import CancellationToken = monaco.CancellationToken;
 import IDisposable = monaco.IDisposable;
 
-//#region utils copied from typescript to prevent loading the entire typescriptServices ---
+//#region utils copied and modified from typescript to prevent loading the entire typescriptServices ---
 
 enum IndentStyle {
 	None = 0,
@@ -41,8 +41,27 @@ export function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessage
 	result += diag.messageText;
 	indent++;
 	if (diag.next) {
-		for (const kid of diag.next) {
-			result += flattenDiagnosticMessageText(kid, newLine, indent);
+		const diagAny = diag as any
+		// Post 3.6 you can iterate through diags
+		if (typeof diagAny.next[Symbol.iterator] === 'function') {
+			for (const kid of diagAny.next) {
+				result += flattenDiagnosticMessageText(kid, newLine, indent);
+			}
+		} else {
+			// In 3.5 and below you iterate through manually, and don't recurse
+			// this is more or less a direct port of the original function from TS 3.5
+			let diagnosticChain = diagAny.next;
+			while (diagnosticChain) {
+				if (indent) {
+					result += newLine;
+					for (let i = 0; i < indent; i++) {
+						result += "  ";
+					}
+				}
+				result += diagnosticChain.messageText;
+				indent++;
+				diagnosticChain = diagnosticChain.next;
+			}
 		}
 	}
 	return result;

File diff suppressed because it is too large
+ 0 - 0
src/lib/lib.ts


File diff suppressed because it is too large
+ 239 - 98
src/lib/typescriptServices-amd.js


File diff suppressed because it is too large
+ 4 - 5
src/lib/typescriptServices.d.ts


File diff suppressed because it is too large
+ 239 - 98
src/lib/typescriptServices.js


Some files were not shown because too many files changed in this diff