@@ -3003,7 +3003,7 @@ var ts;
3003
3003
}
3004
3004
function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
3005
3005
var span = getErrorSpanForNode(node);
3006
- var start = ts.skipTrivia(file.text, span.pos);
3006
+ var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos ;
3007
3007
var length = span.end - start;
3008
3008
file.syntacticErrors.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
3009
3009
}
@@ -6297,16 +6297,51 @@ var ts;
6297
6297
writeCommentRange(comment, writer);
6298
6298
recordSourceMapSpan(comment.end);
6299
6299
}
6300
+ var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
6301
+ var escapedCharsMap = {
6302
+ "\t": "\\t",
6303
+ "\v": "\\v",
6304
+ "\f": "\\f",
6305
+ "\b": "\\b",
6306
+ "\0": "\\0",
6307
+ "\r": "\\r",
6308
+ "\n": "\\n",
6309
+ "\"": "\\\"",
6310
+ "\u2028": "\\u2028",
6311
+ "\u2029": "\\u2029",
6312
+ "\u0085": "\\u0085"
6313
+ };
6314
+ function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
6315
+ if (typeof JSON !== "undefined") {
6316
+ return JSON.stringify({
6317
+ version: version,
6318
+ file: file,
6319
+ sourceRoot: sourceRoot,
6320
+ sources: sources,
6321
+ names: names,
6322
+ mappings: mappings
6323
+ });
6324
+ }
6325
+ return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
6326
+ function escapeString(s) {
6327
+ return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) {
6328
+ return escapedCharsMap[c] || c;
6329
+ }) : s;
6330
+ }
6331
+ function serializeStringArray(list) {
6332
+ var output = "";
6333
+ for (var i = 0, n = list.length; i < n; i++) {
6334
+ if (i) {
6335
+ output += ",";
6336
+ }
6337
+ output += "\"" + escapeString(list[i]) + "\"";
6338
+ }
6339
+ return output;
6340
+ }
6341
+ }
6300
6342
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
6301
6343
encodeLastRecordedSourceMapSpan();
6302
- writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
6303
- version: 3,
6304
- file: sourceMapData.sourceMapFile,
6305
- sourceRoot: sourceMapData.sourceMapSourceRoot,
6306
- sources: sourceMapData.sourceMapSources,
6307
- names: sourceMapData.sourceMapNames,
6308
- mappings: sourceMapData.sourceMapMappings
6309
- }), false);
6344
+ writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
6310
6345
sourceMapDataList.push(sourceMapData);
6311
6346
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
6312
6347
}
@@ -14777,6 +14812,10 @@ var ts;
14777
14812
function executeCommandLine(args) {
14778
14813
var commandLine = ts.parseCommandLine(args);
14779
14814
if (commandLine.options.locale) {
14815
+ if (typeof JSON === "undefined") {
14816
+ reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
14817
+ return sys.exit(1);
14818
+ }
14780
14819
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
14781
14820
}
14782
14821
if (commandLine.errors.length > 0) {
0 commit comments