Adds backwards compatability for diagnostic chains

This commit is contained in:
Orta Therox 2019-08-29 12:30:59 -04:00
parent 7e5cb3e7ac
commit c8b92c097f
8 changed files with 15576 additions and 8652 deletions

8
package-lock.json generated
View file

@ -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": {

View file

@ -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"
}
}

View file

@ -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() {

View file

@ -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,9 +41,28 @@ export function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessage
result += diag.messageText;
indent++;
if (diag.next) {
for (const kid of diag.next) {
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 one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long