diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 004a4f3b26..b2b55085af 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -2387,7 +2387,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_Colon, typeToString(type), typeName1, typeName2);
- addDiagnostic(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
+ addDiagnostic(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine()));
}
}
}
@@ -2434,7 +2434,7 @@ module ts {
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
}
else if (errorInfo) {
- addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo));
+ addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine()));
}
return result;
diff --git a/src/compiler/core.ts b/src/compiler/core.ts
index 8e59408f15..6f9f2629a8 100644
--- a/src/compiler/core.ts
+++ b/src/compiler/core.ts
@@ -214,7 +214,7 @@ module ts {
}
}
- export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain): Diagnostic {
+ export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@@ -222,7 +222,7 @@ module ts {
var indent = 0;
while (diagnosticChain) {
if (indent) {
- messageText += sys.newLine;
+ messageText += newLine;
for (var i = 0; i < indent; i++) {
messageText += " ";
diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index d1e2367bab..a80845d852 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -22,6 +22,7 @@ module ts {
var compilerOptions = program.getCompilerOptions();
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
var diagnostics: Diagnostic[] = [];
+ var newLine = program.getCompilerHost().getNewLine();
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
@@ -126,7 +127,7 @@ module ts {
function writeLine() {
if (!lineStart) {
- output += sys.newLine;
+ output += newLine;
lineCount++;
linePos = output.length;
lineStart = true;
@@ -2252,7 +2253,7 @@ module ts {
compilerHost.getCurrentDirectory(),
/*isAbsolutePathAnUrl*/ false);
- referencePathsOutput += "/// " + sys.newLine;
+ referencePathsOutput += "/// " + newLine;
}
if (root) {
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index f0f7c36e44..1536d0c00d 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -88,12 +88,12 @@ module ts {
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
}
- export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic {
+ export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): 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);
+ return flattenDiagnosticChain(file, start, length, messageChain, newLine);
}
export function getErrorSpanForNode(node: Node): Node {
diff --git a/src/compiler/tc.ts b/src/compiler/tc.ts
index d44d1b9724..26dc7631b9 100644
--- a/src/compiler/tc.ts
+++ b/src/compiler/tc.ts
@@ -162,7 +162,8 @@ module ts {
writeFile: writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
- getCanonicalFileName: getCanonicalFileName
+ getCanonicalFileName: getCanonicalFileName,
+ getNewLine: () => sys.newLine
};
}
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 6b846768c1..825e214758 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -1104,5 +1104,6 @@ module ts {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
+ getNewLine(): string;
}
}