From b12be3db1909164642f7dd04d5b78a4aa0efd489 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 4 Feb 2015 23:20:26 -0800 Subject: [PATCH] Remove dependency from the typechecker to the compiler host. This also lets us not expose the compiler host from the Program instance. The compiler host was only needed by the type checker to get the host newline. The host newline was used for concatenating diagnostic message chains. Now we don't concatenate them up front. Instead, we just store the message chain in the diagnostic itself. Then when we pass it to the host, it can then decide what newline to use. --- src/compiler/checker.ts | 4 +- src/compiler/core.ts | 58 ++++++++----------- src/compiler/program.ts | 16 +++-- src/compiler/tsc.ts | 6 +- src/compiler/types.ts | 6 +- src/compiler/utilities.ts | 37 +++++++++++- src/harness/fourslash.ts | 11 +++- src/harness/harness.ts | 8 ++- src/harness/harnessLanguageService.ts | 4 ++ src/harness/projectsRunner.ts | 4 +- src/services/shims.ts | 15 +++-- .../baselines/reference/APISample_compile.js | 6 +- .../reference/APISample_compile.types | 19 ++---- tests/baselines/reference/APISample_linter.js | 6 +- .../reference/APISample_linter.types | 15 ++--- .../reference/APISample_transform.js | 6 +- .../reference/APISample_transform.types | 19 ++---- .../baselines/reference/APISample_watcher.js | 6 +- .../reference/APISample_watcher.types | 23 +++----- 19 files changed, 135 insertions(+), 134 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 945dc4d7a2a..50dcbd21fdc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3476,7 +3476,7 @@ module ts { errorInfo = concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); } - diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, host.getCompilerHost().getNewLine())); + diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } return result !== Ternary.False; @@ -8924,7 +8924,7 @@ module ts { var errorInfo = chainDiagnosticMessages(undefined, Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - diagnostics.add(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, host.getCompilerHost().getNewLine())); + diagnostics.add(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 87094150baf..9b852a37ff6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -325,38 +325,6 @@ module ts { return headChain; } - export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic { - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - - var code = diagnosticChain.code; - var category = diagnosticChain.category; - var messageText = ""; - - var indent = 0; - while (diagnosticChain) { - if (indent) { - messageText += newLine; - - for (var i = 0; i < indent; i++) { - messageText += " "; - } - } - messageText += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - - return { - file, - start, - length, - code, - category, - messageText - }; - } - export function compareValues(a: T, b: T): Comparison { if (a === b) return Comparison.EqualTo; if (a === undefined) return Comparison.LessThan; @@ -373,10 +341,34 @@ module ts { compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(d1.code, d2.code) || - compareValues(d1.messageText, d2.messageText) || + compareMessageText(d1.messageText, d2.messageText) || 0; } + function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): number { + while (text1 && text2) { + // We still have both chains. + var string1 = typeof text1 === "string" ? text1 : text1.messageText; + var string2 = typeof text2 === "string" ? text2 : text2.messageText; + + var res = compareValues(string1, string2); + if (res) { + return res; + } + + text1 = typeof text1 === "string" ? undefined : text1.next; + text2 = typeof text2 === "string" ? undefined : text2.next; + } + + if (!text1 && !text2) { + // if the chains are done, then these messages are the same. + return 0; + } + + // We still have one chain remaining. The shorter chain should come first. + return text1 ? 1 : -1; + } + export function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[] { if (diagnostics.length < 2) { return diagnostics; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c28ca61e548..85181b2aa55 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -23,9 +23,9 @@ module ts { } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode ? - createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText : - e.message); + onError(e.number === unsupportedFileEncodingErrorCode + ? createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText + : e.message); } text = ""; } @@ -97,7 +97,6 @@ module ts { getSourceFile: getSourceFile, getSourceFiles: () => files, getCompilerOptions: () => options, - getCompilerHost: () => host, getDiagnostics, getGlobalDiagnostics, getTypeCheckerDiagnostics, @@ -118,17 +117,16 @@ module ts { return program; function getEmitHost(writeFileCallback?: WriteFileCallback) { - var compilerHost = program.getCompilerHost(); return { - getCanonicalFileName: compilerHost.getCanonicalFileName, + getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: compilerHost.getCurrentDirectory, - getNewLine: compilerHost.getNewLine, + getCurrentDirectory: host.getCurrentDirectory, + getNewLine: host.getNewLine, getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, isEmitBlocked, - writeFile: writeFileCallback || compilerHost.writeFile, + writeFile: writeFileCallback || host.writeFile, }; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index f0dcb872950..15f97e028fc 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -78,8 +78,8 @@ module ts { } function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string { - var diagnostic: Diagnostic = createCompilerDiagnostic.apply(undefined, arguments); - return diagnostic.messageText; + var diagnostic = createCompilerDiagnostic.apply(undefined, arguments); + return diagnostic.messageText; } function reportDiagnostic(diagnostic: Diagnostic) { @@ -92,7 +92,7 @@ module ts { } var category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine; + output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine; sys.write(output); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 60d19b4a5d3..467d9b6cc90 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -933,7 +933,6 @@ module ts { export interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; - getCompilerHost(): CompilerHost; /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then @@ -941,7 +940,7 @@ module ts { * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -1009,7 +1008,6 @@ module ts { export interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; getSourceFile(fileName: string): SourceFile; @@ -1451,7 +1449,7 @@ module ts { file: SourceFile; start: number; length: number; - messageText: string; + messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9df23b22dd0..4204acc4716 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -199,12 +199,45 @@ module ts { return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } - export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic { + export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); var start = skipTrivia(file.text, node.pos); var length = node.end - start; - return flattenDiagnosticChain(file, start, length, messageChain, newLine); + return { + file, + start, + length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain + }; + } + + export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + + return result; + } } export function getErrorSpanForNode(node: Node): Node { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index dd55e702d09..5e046c070ab 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -513,7 +513,9 @@ module FourSlash { } errors.forEach(function (error: ts.Diagnostic) { - Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + error.messageText + "\n"); + Harness.IO.log(" minChar: " + error.start + + ", limChar: " + (error.start + error.length) + + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n"); }); } @@ -1179,7 +1181,10 @@ module FourSlash { if (errorList.length) { errorList.forEach(err => { - Harness.IO.log("start: " + err.start + ", length: " + err.length + ", message: " + err.messageText); + Harness.IO.log( + "start: " + err.start + + ", length: " + err.length + + ", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine)); }); } } @@ -2214,7 +2219,7 @@ module FourSlash { var errors = program.getDiagnostics().concat(checker.getDiagnostics()); if (errors.length > 0) { - throw new Error('Error compiling ' + fileName + ': ' + errors.map(e => e.messageText).join('\r\n')); + throw new Error('Error compiling ' + fileName + ': ' + errors.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join('\r\n')); } program.emit(); result = result || ''; // Might have an empty fourslash file diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a7d107c66d5..84aaf66be3d 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -183,7 +183,7 @@ module Utils { return { start: diagnostic.start, length: diagnostic.length, - messageText: diagnostic.messageText, + messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine), category: (ts).DiagnosticCategory[diagnostic.category], code: diagnostic.code }; @@ -305,7 +305,9 @@ module Utils { assert.equal(d1.start, d2.start, "d1.start !== d2.start"); assert.equal(d1.length, d2.length, "d1.length !== d2.length"); - assert.equal(d1.messageText, d2.messageText, "d1.messageText !== d2.messageText"); + assert.equal( + ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine), + ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText"); assert.equal(d1.category, d2.category, "d1.category !== d2.category"); assert.equal(d1.code, d2.code, "d1.code !== d2.code"); } @@ -1182,7 +1184,7 @@ module Harness { end: err.start + err.length, line: errorLineInfo.line, character: errorLineInfo.character, - message: err.messageText, + message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine), category: ts.DiagnosticCategory[err.category].toLowerCase(), code: err.code }; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index d7510c7879e..547f8ccce48 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -134,6 +134,10 @@ module Harness.LanguageService { public trace(s: string) { } + public getNewLine(): string { + return "\r\n"; + } + public addDefaultLibrary() { this.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 327ebc3520e..53ce8e507a0 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -275,14 +275,14 @@ class ProjectRunner extends RunnerBase { function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) { var allInputFiles: { emittedFileName: string; code: string; }[] = []; var compilerOptions = compilerResult.program.getCompilerOptions(); - var compilerHost = compilerResult.program.getCompilerHost(); + ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => { if (Harness.Compiler.isDTS(sourceFile.fileName)) { allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text }); } else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) { if (compilerOptions.outDir) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerHost.getCurrentDirectory()); + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory()); sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), ""); var emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath)); } diff --git a/src/services/shims.ts b/src/services/shims.ts index c5b2b24108d..8b7a48d03f3 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -52,6 +52,7 @@ module ts { getCancellationToken(): CancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: string): string; + getNewLine?(): string; } /// @@ -367,9 +368,9 @@ module ts { }); } - private static realizeDiagnostic(diagnostic: Diagnostic): { message: string; start: number; length: number; category: string; } { + private realizeDiagnostic(diagnostic: Diagnostic, newLine?: string): { message: string; start: number; length: number; category: string; } { return { - message: diagnostic.messageText, + message: flattenDiagnosticMessageText(diagnostic.messageText, newLine), start: diagnostic.start, length: diagnostic.length, /// TODO: no need for the tolowerCase call @@ -396,12 +397,16 @@ module ts { }); } + private getNewLine(): string { + return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; + } + public getSyntacticDiagnostics(fileName: string): string { return this.forwardJSONCall( "getSyntacticDiagnostics('" + fileName + "')", () => { var errors = this.languageService.getSyntacticDiagnostics(fileName); - return errors.map(LanguageServiceShimObject.realizeDiagnostic); + return errors.map(e => this.realizeDiagnostic(e), this.getNewLine()); }); } @@ -410,7 +415,7 @@ module ts { "getSemanticDiagnostics('" + fileName + "')", () => { var errors = this.languageService.getSemanticDiagnostics(fileName); - return errors.map(LanguageServiceShimObject.realizeDiagnostic); + return errors.map(e => this.realizeDiagnostic(e), this.getNewLine()); }); } @@ -419,7 +424,7 @@ module ts { "getCompilerOptionsDiagnostics()", () => { var errors = this.languageService.getCompilerOptionsDiagnostics(); - return errors.map(LanguageServiceShimObject.realizeDiagnostic) + return errors.map(e => this.realizeDiagnostic(e), this.getNewLine()) }); } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f057f673607..db4f29683d2 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -741,14 +741,13 @@ declare module "typescript" { } interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; - getCompilerHost(): CompilerHost; /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -795,7 +794,6 @@ declare module "typescript" { } interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; getSourceFile(fileName: string): SourceFile; } @@ -1144,7 +1142,7 @@ declare module "typescript" { file: SourceFile; start: number; length: number; - messageText: string; + messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; } diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 00a34474041..5124312b6d3 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -98,9 +98,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void >lineChar.character : number >lineChar : ts.LineAndCharacter >character : number ->diagnostic.messageText : string +>diagnostic.messageText : string | ts.DiagnosticMessageChain >diagnostic : ts.Diagnostic ->messageText : string +>messageText : string | ts.DiagnosticMessageChain }); @@ -2250,17 +2250,13 @@ declare module "typescript" { >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -2400,10 +2396,6 @@ declare module "typescript" { >getCompilerOptions : () => CompilerOptions >CompilerOptions : CompilerOptions - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - getSourceFiles(): SourceFile[]; >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile @@ -3659,8 +3651,9 @@ declare module "typescript" { length: number; >length : number - messageText: string; ->messageText : string + messageText: string | DiagnosticMessageChain; +>messageText : string | DiagnosticMessageChain +>DiagnosticMessageChain : DiagnosticMessageChain category: DiagnosticCategory; >category : DiagnosticCategory diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index bc4b118891a..646d0e47a4e 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -772,14 +772,13 @@ declare module "typescript" { } interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; - getCompilerHost(): CompilerHost; /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -826,7 +825,6 @@ declare module "typescript" { } interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; getSourceFile(fileName: string): SourceFile; } @@ -1175,7 +1173,7 @@ declare module "typescript" { file: SourceFile; start: number; length: number; - messageText: string; + messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; } diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 3fbd07f08d8..1e917893832 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2397,17 +2397,13 @@ declare module "typescript" { >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -2547,10 +2543,6 @@ declare module "typescript" { >getCompilerOptions : () => CompilerOptions >CompilerOptions : CompilerOptions - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - getSourceFiles(): SourceFile[]; >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile @@ -3806,8 +3798,9 @@ declare module "typescript" { length: number; >length : number - messageText: string; ->messageText : string + messageText: string | DiagnosticMessageChain; +>messageText : string | DiagnosticMessageChain +>DiagnosticMessageChain : DiagnosticMessageChain category: DiagnosticCategory; >category : DiagnosticCategory diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 4b50058a855..280c5202db3 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -772,14 +772,13 @@ declare module "typescript" { } interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; - getCompilerHost(): CompilerHost; /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -826,7 +825,6 @@ declare module "typescript" { } interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; getSourceFile(fileName: string): SourceFile; } @@ -1175,7 +1173,7 @@ declare module "typescript" { file: SourceFile; start: number; length: number; - messageText: string; + messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; } diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 3882bd50445..c8b7e10fa89 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -212,9 +212,9 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) { >e : ts.Diagnostic >start : number >line : number ->e.messageText : string +>e.messageText : string | ts.DiagnosticMessageChain >e : ts.Diagnostic ->messageText : string +>messageText : string | ts.DiagnosticMessageChain }; } @@ -2338,17 +2338,13 @@ declare module "typescript" { >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -2488,10 +2484,6 @@ declare module "typescript" { >getCompilerOptions : () => CompilerOptions >CompilerOptions : CompilerOptions - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - getSourceFiles(): SourceFile[]; >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile @@ -3747,8 +3739,9 @@ declare module "typescript" { length: number; >length : number - messageText: string; ->messageText : string + messageText: string | DiagnosticMessageChain; +>messageText : string | DiagnosticMessageChain +>DiagnosticMessageChain : DiagnosticMessageChain category: DiagnosticCategory; >category : DiagnosticCategory diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 5f99e7beefb..89f3bc43d37 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -810,14 +810,13 @@ declare module "typescript" { } interface Program extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; - getCompilerHost(): CompilerHost; /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -864,7 +863,6 @@ declare module "typescript" { } interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; - getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; getSourceFile(fileName: string): SourceFile; } @@ -1213,7 +1211,7 @@ declare module "typescript" { file: SourceFile; start: number; length: number; - messageText: string; + messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; } diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index dadd3a08cea..f286fe18eb2 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -362,9 +362,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >lineChar.character : number >lineChar : ts.LineAndCharacter >character : number ->diagnostic.messageText : string +>diagnostic.messageText : string | ts.DiagnosticMessageChain >diagnostic : ts.Diagnostic ->messageText : string +>messageText : string | ts.DiagnosticMessageChain } else { console.log(` Error: ${diagnostic.messageText}`); @@ -372,9 +372,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >console.log : any >console : any >log : any ->diagnostic.messageText : string +>diagnostic.messageText : string | ts.DiagnosticMessageChain >diagnostic : ts.Diagnostic ->messageText : string +>messageText : string | ts.DiagnosticMessageChain } }); } @@ -2523,17 +2523,13 @@ declare module "typescript" { >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - /** * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that * specific file will be generated. * - * If writeFile is not specified then the writeFile callback from getCompilerHost() will be + * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the javascript and declaration files. */ @@ -2673,10 +2669,6 @@ declare module "typescript" { >getCompilerOptions : () => CompilerOptions >CompilerOptions : CompilerOptions - getCompilerHost(): CompilerHost; ->getCompilerHost : () => CompilerHost ->CompilerHost : CompilerHost - getSourceFiles(): SourceFile[]; >getSourceFiles : () => SourceFile[] >SourceFile : SourceFile @@ -3932,8 +3924,9 @@ declare module "typescript" { length: number; >length : number - messageText: string; ->messageText : string + messageText: string | DiagnosticMessageChain; +>messageText : string | DiagnosticMessageChain +>DiagnosticMessageChain : DiagnosticMessageChain category: DiagnosticCategory; >category : DiagnosticCategory