@@ -444,7 +444,7 @@ var ts;
444
444
for (var _i = 0; _i < parts.length; _i++) {
445
445
var part = parts[_i];
446
446
if (part !== ".") {
447
- if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
447
+ if (part === ".." && normalized.length > 0 && lastOrUndefined( normalized) !== "..") {
448
448
normalized.pop();
449
449
}
450
450
else {
@@ -536,7 +536,7 @@ var ts;
536
536
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
537
537
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
538
538
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
539
- if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
539
+ if (directoryComponents.length > 1 && lastOrUndefined( directoryComponents) === "") {
540
540
directoryComponents.length--;
541
541
}
542
542
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
@@ -1416,6 +1416,9 @@ var ts;
1416
1416
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
1417
1417
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
1418
1418
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
1419
+ Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
1420
+ NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
1421
+ Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
1419
1422
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
1420
1423
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
1421
1424
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -1844,7 +1847,7 @@ var ts;
1844
1847
}
1845
1848
collecting = true;
1846
1849
if (result && result.length) {
1847
- result[result.length - 1] .hasTrailingNewLine = true;
1850
+ ts.lastOrUndefined(result) .hasTrailingNewLine = true;
1848
1851
}
1849
1852
continue;
1850
1853
case 9:
@@ -1890,7 +1893,7 @@ var ts;
1890
1893
default:
1891
1894
if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) {
1892
1895
if (result && result.length && isLineBreak(ch)) {
1893
- result[result.length - 1] .hasTrailingNewLine = true;
1896
+ ts.lastOrUndefined(result) .hasTrailingNewLine = true;
1894
1897
}
1895
1898
pos++;
1896
1899
continue;
@@ -3908,7 +3911,7 @@ var ts;
3908
3911
}
3909
3912
ts.hasQuestionToken = hasQuestionToken;
3910
3913
function hasRestParameters(s) {
3911
- return s.parameters.length > 0 && s.parameters[ s.parameters.length - 1] .dotDotDotToken !== undefined;
3914
+ return s.parameters.length > 0 && ts.lastOrUndefined( s.parameters) .dotDotDotToken !== undefined;
3912
3915
}
3913
3916
ts.hasRestParameters = hasRestParameters;
3914
3917
function isLiteralKind(kind) {
@@ -4336,7 +4339,7 @@ var ts;
4336
4339
var lineStartsOfS = ts.computeLineStarts(s);
4337
4340
if (lineStartsOfS.length > 1) {
4338
4341
lineCount = lineCount + lineStartsOfS.length - 1;
4339
- linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1] ;
4342
+ linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS) ;
4340
4343
}
4341
4344
}
4342
4345
}
@@ -4405,8 +4408,8 @@ var ts;
4405
4408
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
4406
4409
function shouldEmitToOwnFile(sourceFile, compilerOptions) {
4407
4410
if (!isDeclarationFile(sourceFile)) {
4408
- if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js") ) {
4409
- return true ;
4411
+ if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
4412
+ return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js") ;
4410
4413
}
4411
4414
return false;
4412
4415
}
@@ -5981,7 +5984,7 @@ var ts;
5981
5984
templateSpans.pos = getNodePos();
5982
5985
do {
5983
5986
templateSpans.push(parseTemplateSpan());
5984
- } while (templateSpans[templateSpans.length - 1] .literal.kind === 12);
5987
+ } while (ts.lastOrUndefined(templateSpans) .literal.kind === 12);
5985
5988
templateSpans.end = getNodeEnd();
5986
5989
template.templateSpans = templateSpans;
5987
5990
return finishNode(template);
@@ -11125,7 +11128,7 @@ var ts;
11125
11128
}
11126
11129
function getRestTypeOfSignature(signature) {
11127
11130
if (signature.hasRestParameter) {
11128
- var type = getTypeOfSymbol(signature.parameters[ signature.parameters.length - 1] );
11131
+ var type = getTypeOfSymbol(ts.lastOrUndefined( signature.parameters) );
11129
11132
if (type.flags & 4096 && type.target === globalArrayType) {
11130
11133
return type.typeArguments[0];
11131
11134
}
@@ -13219,7 +13222,7 @@ var ts;
13219
13222
}
13220
13223
if (indexOfParameter === (func.parameters.length - 1) &&
13221
13224
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
13222
- return getTypeOfSymbol(contextualSignature.parameters[ contextualSignature.parameters.length - 1] );
13225
+ return getTypeOfSymbol(ts.lastOrUndefined( contextualSignature.parameters) );
13223
13226
}
13224
13227
}
13225
13228
}
@@ -14279,9 +14282,9 @@ var ts;
14279
14282
links.type = instantiateType(getTypeAtPosition(context, i), mapper);
14280
14283
}
14281
14284
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
14282
- var parameter = signature.parameters[ signature.parameters.length - 1] ;
14285
+ var parameter = ts.lastOrUndefined( signature.parameters) ;
14283
14286
var links = getSymbolLinks(parameter);
14284
- links.type = instantiateType(getTypeOfSymbol(context.parameters[ context.parameters.length - 1] ), mapper);
14287
+ links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined( context.parameters) ), mapper);
14285
14288
}
14286
14289
}
14287
14290
function getReturnTypeFromBody(func, contextualMapper) {
@@ -18660,7 +18663,7 @@ var ts;
18660
18663
function checkGrammarBindingElement(node) {
18661
18664
if (node.dotDotDotToken) {
18662
18665
var elements = node.parent.elements;
18663
- if (node !== elements[elements.length - 1] ) {
18666
+ if (node !== ts.lastOrUndefined(elements) ) {
18664
18667
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
18665
18668
}
18666
18669
if (node.name.kind === 152 || node.name.kind === 151) {
@@ -20446,7 +20449,7 @@ var ts;
20446
20449
var sourceMapNameIndexMap = {};
20447
20450
var sourceMapNameIndices = [];
20448
20451
function getSourceMapNameIndex() {
20449
- return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
20452
+ return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
20450
20453
}
20451
20454
var lastRecordedSourceMapSpan;
20452
20455
var lastEncodedSourceMapSpan = {
@@ -22922,11 +22925,11 @@ var ts;
22922
22925
emitNodeWithoutSourceMap(memberName);
22923
22926
}
22924
22927
}
22925
- function getInitializedProperties(node, static ) {
22928
+ function getInitializedProperties(node, isStatic ) {
22926
22929
var properties = [];
22927
22930
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
22928
22931
var member = _b[_a];
22929
- if (member.kind === 133 && static === ((member.flags & 128) !== 0) && member.initializer) {
22932
+ if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) {
22930
22933
properties.push(member);
22931
22934
}
22932
22935
}
@@ -24834,10 +24837,10 @@ var ts;
24834
24837
}
24835
24838
}
24836
24839
function hasDetachedComments(pos) {
24837
- return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1] .nodePos === pos;
24840
+ return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo) .nodePos === pos;
24838
24841
}
24839
24842
function getLeadingCommentsWithoutDetachedComments() {
24840
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1] .detachedCommentEndPos);
24843
+ var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo) .detachedCommentEndPos);
24841
24844
if (detachedCommentsInfo.length - 1) {
24842
24845
detachedCommentsInfo.pop();
24843
24846
}
@@ -24918,12 +24921,12 @@ var ts;
24918
24921
lastComment = comment;
24919
24922
});
24920
24923
if (detachedComments.length) {
24921
- var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1] .end);
24924
+ var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments) .end);
24922
24925
var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
24923
24926
if (nodeLine >= lastCommentLine + 2) {
24924
24927
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
24925
24928
ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
24926
- var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1] .end };
24929
+ var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments) .end };
24927
24930
if (detachedCommentsInfo) {
24928
24931
detachedCommentsInfo.push(currentDetachedCommentInfo);
24929
24932
}
@@ -24964,6 +24967,8 @@ var ts;
24964
24967
ts.ioReadTime = 0;
24965
24968
ts.ioWriteTime = 0;
24966
24969
ts.version = "1.5.0";
24970
+ var carriageReturnLineFeed = "\r\n";
24971
+ var lineFeed = "\n";
24967
24972
function findConfigFile(searchPath) {
24968
24973
var fileName = "tsconfig.json";
24969
24974
while (true) {
@@ -25034,14 +25039,17 @@ var ts;
25034
25039
}
25035
25040
}
25036
25041
}
25042
+ var newLine = options.newLine === 0 ? carriageReturnLineFeed :
25043
+ options.newLine === 1 ? lineFeed :
25044
+ ts.sys.newLine;
25037
25045
return {
25038
25046
getSourceFile: getSourceFile,
25039
25047
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
25040
25048
writeFile: writeFile,
25041
25049
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
25042
25050
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
25043
25051
getCanonicalFileName: getCanonicalFileName,
25044
- getNewLine: function () { return ts.sys. newLine; }
25052
+ getNewLine: function () { return newLine; }
25045
25053
};
25046
25054
}
25047
25055
ts.createCompilerHost = createCompilerHost;
@@ -25526,6 +25534,16 @@ var ts;
25526
25534
paramType: ts.Diagnostics.KIND,
25527
25535
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
25528
25536
},
25537
+ {
25538
+ name: "newLine",
25539
+ type: {
25540
+ "crlf": 0,
25541
+ "lf": 1
25542
+ },
25543
+ description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
25544
+ paramType: ts.Diagnostics.NEWLINE,
25545
+ error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
25546
+ },
25529
25547
{
25530
25548
name: "noEmit",
25531
25549
type: "boolean",
0 commit comments