Skip to content

Commit 30a49db

Browse files
Merge pull request #932 from Microsoft/breakCycleInDiagnosticGeneration
Removed Diagnostics from sys.ts in order to avoid cyclical build dependency
2 parents a6eb698 + b371b02 commit 30a49db

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var sys: System = (function () {
6868
return fileStream.ReadText();
6969
}
7070
catch (e) {
71-
throw e.number === -2147024809 ? new Error(ts.Diagnostics.Unsupported_file_encoding.key) : e;
71+
throw e;
7272
}
7373
finally {
7474
fileStream.Close();

src/compiler/tsc.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,19 @@ module ts {
142142
// otherwise use toLowerCase as a canonical form.
143143
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
144144
}
145-
145+
146+
// returned by CScript sys environment
147+
var unsupportedFileEncodingErrorCode = -2147024809;
148+
146149
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
147150
try {
148151
var text = sys.readFile(filename, options.charset);
149152
}
150153
catch (e) {
151154
if (onError) {
152-
onError(e.message);
155+
onError(e.number === unsupportedFileEncodingErrorCode ?
156+
getDiagnosticText(Diagnostics.Unsupported_file_encoding) :
157+
e.message);
153158
}
154159
text = "";
155160
}

0 commit comments

Comments
 (0)