瀏覽代碼

Adds support for running on TS 3.6.0, and adds a daily update script

Orta Therox 6 年之前
父節點
當前提交
8440cba727
共有 3 個文件被更改,包括 50 次插入19 次删除
  1. 3 2
      package.json
  2. 27 0
      scripts/runDaily.js
  3. 20 17
      src/languageFeatures.ts

+ 3 - 2
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "monaco-typescript",
   "name": "monaco-typescript",
-  "version": "3.5.0",
+  "version": "3.6.0",
   "description": "TypeScript and JavaScript language support for Monaco Editor",
   "description": "TypeScript and JavaScript language support for Monaco Editor",
   "scripts": {
   "scripts": {
     "compile-amd": "mcopy ./src/lib/typescriptServices-amd.js ./release/dev/lib/typescriptServices.js && tsc -p ./src/tsconfig.json",
     "compile-amd": "mcopy ./src/lib/typescriptServices-amd.js ./release/dev/lib/typescriptServices.js && tsc -p ./src/tsconfig.json",
@@ -8,7 +8,8 @@
     "compile": "mrmdir ./release && npm run compile-amd && npm run compile-esm",
     "compile": "mrmdir ./release && npm run compile-amd && npm run compile-esm",
     "watch": "tsc -p ./src --watch",
     "watch": "tsc -p ./src --watch",
     "prepublishOnly": "npm run compile && node ./scripts/bundle && mcopy ./src/monaco.d.ts ./release/monaco.d.ts",
     "prepublishOnly": "npm run compile && node ./scripts/bundle && mcopy ./src/monaco.d.ts ./release/monaco.d.ts",
-    "import-typescript": "node ./scripts/importTypescript"
+    "import-typescript": "node ./scripts/importTypescript",
+    "run-nightly": "node ./scripts/runDaily",
   },
   },
   "author": "Microsoft Corporation",
   "author": "Microsoft Corporation",
   "license": "MIT",
   "license": "MIT",

+ 27 - 0
scripts/runDaily.js

@@ -0,0 +1,27 @@
+// @ts-check
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+const {execSync} = require('child_process');
+const {join} = require('path')
+const {readFileSync, writeFileSync} = require("fs")
+
+// Update to the daily build
+execSync("npm install --save typescript@next")
+
+// Update the dts files
+execSync("npm run import-typescript")
+
+// Sync the versions
+const packagePath = join(__dirname, "../package.json")
+const package = JSON.parse(readFileSync(packagePath, "utf8"))
+
+const tsPackagePath = join(__dirname, "../node_modules/typescript/package.json")
+const tsPackage = JSON.parse(readFileSync(tsPackagePath, "utf8"))
+
+// Set the monaco-typescript version to directly match the typescript nightly version
+package.version = tsPackage.version
+writeFileSync(packagePath, JSON.stringify(package), "utf8")
+

+ 20 - 17
src/languageFeatures.ts

@@ -23,26 +23,29 @@ enum IndentStyle {
 	Smart = 2
 	Smart = 2
 }
 }
 
 
-function flattenDiagnosticMessageText(messageText: string | ts.DiagnosticMessageChain, newLine: '\n'): string {
-	if (typeof messageText === "string") {
-		return messageText;
-	} else {
-		let diagnosticChain = messageText;
-		let result = "";
-		let indent = 0;
-		while (diagnosticChain) {
-			if (indent) {
-				result += newLine;
-				for (let i = 0; i < indent; i++) {
+export function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessageChain | undefined, newLine: string, indent = 0): string {
+	if (typeof diag === "string") {
+			return diag;
+	}
+	else if (diag === undefined) {
+			return "";
+	}
+	let result = "";
+	if (indent) {
+			result += newLine;
+
+			for (let i = 0; i < indent; i++) {
 					result += "  ";
 					result += "  ";
-				}
 			}
 			}
-			result += diagnosticChain.messageText;
-			indent++;
-			diagnosticChain = diagnosticChain.next;
-		}
-		return result;
 	}
 	}
+	result += diag.messageText;
+	indent++;
+	if (diag.next) {
+			for (const kid of diag.next) {
+					result += flattenDiagnosticMessageText(kid, newLine, indent);
+			}
+	}
+	return result;
 }
 }
 
 
 function displayPartsToString(displayParts: ts.SymbolDisplayPart[]): string {
 function displayPartsToString(displayParts: ts.SymbolDisplayPart[]): string {