Skip to content

Commit dbf8764

Browse files
committed
Update LKG
1 parent 09d6e4a commit dbf8764

File tree

2 files changed

+92
-18
lines changed

2 files changed

+92
-18
lines changed

bin/tsc.js

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,7 @@ var ts;
30033003
}
30043004
function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
30053005
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;
30073007
var length = span.end - start;
30083008
file.syntacticErrors.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
30093009
}
@@ -6297,16 +6297,51 @@ var ts;
62976297
writeCommentRange(comment, writer);
62986298
recordSourceMapSpan(comment.end);
62996299
}
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+
}
63006342
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
63016343
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);
63106345
sourceMapDataList.push(sourceMapData);
63116346
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
63126347
}
@@ -14777,6 +14812,10 @@ var ts;
1477714812
function executeCommandLine(args) {
1477814813
var commandLine = ts.parseCommandLine(args);
1477914814
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+
}
1478014819
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
1478114820
}
1478214821
if (commandLine.errors.length > 0) {

bin/typescriptServices.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ var ts;
28082808
}
28092809
function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
28102810
var span = getErrorSpanForNode(node);
2811-
var start = ts.skipTrivia(file.text, span.pos);
2811+
var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos;
28122812
var length = span.end - start;
28132813
file.syntacticErrors.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2));
28142814
}
@@ -6102,16 +6102,51 @@ var ts;
61026102
writeCommentRange(comment, writer);
61036103
recordSourceMapSpan(comment.end);
61046104
}
6105+
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
6106+
var escapedCharsMap = {
6107+
"\t": "\\t",
6108+
"\v": "\\v",
6109+
"\f": "\\f",
6110+
"\b": "\\b",
6111+
"\0": "\\0",
6112+
"\r": "\\r",
6113+
"\n": "\\n",
6114+
"\"": "\\\"",
6115+
"\u2028": "\\u2028",
6116+
"\u2029": "\\u2029",
6117+
"\u0085": "\\u0085"
6118+
};
6119+
function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
6120+
if (typeof JSON !== "undefined") {
6121+
return JSON.stringify({
6122+
version: version,
6123+
file: file,
6124+
sourceRoot: sourceRoot,
6125+
sources: sources,
6126+
names: names,
6127+
mappings: mappings
6128+
});
6129+
}
6130+
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
6131+
function escapeString(s) {
6132+
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) {
6133+
return escapedCharsMap[c] || c;
6134+
}) : s;
6135+
}
6136+
function serializeStringArray(list) {
6137+
var output = "";
6138+
for (var i = 0, n = list.length; i < n; i++) {
6139+
if (i) {
6140+
output += ",";
6141+
}
6142+
output += "\"" + escapeString(list[i]) + "\"";
6143+
}
6144+
return output;
6145+
}
6146+
}
61056147
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
61066148
encodeLastRecordedSourceMapSpan();
6107-
writeFile(sourceMapData.sourceMapFilePath, JSON.stringify({
6108-
version: 3,
6109-
file: sourceMapData.sourceMapFile,
6110-
sourceRoot: sourceMapData.sourceMapSourceRoot,
6111-
sources: sourceMapData.sourceMapSources,
6112-
names: sourceMapData.sourceMapNames,
6113-
mappings: sourceMapData.sourceMapMappings
6114-
}), false);
6149+
writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
61156150
sourceMapDataList.push(sourceMapData);
61166151
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
61176152
}

0 commit comments

Comments
 (0)