From 8440cba7279fcce86bc0af392d2fca5a400627e9 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 24 Jul 2019 09:00:05 -0400 Subject: [PATCH] Adds support for running on TS 3.6.0, and adds a daily update script --- package.json | 5 +++-- scripts/runDaily.js | 27 +++++++++++++++++++++++++++ src/languageFeatures.ts | 37 ++++++++++++++++++++----------------- 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 scripts/runDaily.js diff --git a/package.json b/package.json index 948a2897..9a2916d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monaco-typescript", - "version": "3.5.0", + "version": "3.6.0", "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", @@ -8,7 +8,8 @@ "compile": "mrmdir ./release && npm run compile-amd && npm run compile-esm", "watch": "tsc -p ./src --watch", "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", "license": "MIT", diff --git a/scripts/runDaily.js b/scripts/runDaily.js new file mode 100644 index 00000000..e9eed03c --- /dev/null +++ b/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") + diff --git a/src/languageFeatures.ts b/src/languageFeatures.ts index cc76509c..d51701b4 100644 --- a/src/languageFeatures.ts +++ b/src/languageFeatures.ts @@ -23,26 +23,29 @@ enum IndentStyle { 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 += 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 {