@@ -444,7 +444,7 @@ var ts;
444444 for (var _i = 0; _i < parts.length; _i++) {
445445 var part = parts[_i];
446446 if (part !== ".") {
447- if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
447+ if (part === ".." && normalized.length > 0 && lastOrUndefined( normalized) !== "..") {
448448 normalized.pop();
449449 }
450450 else {
@@ -536,7 +536,7 @@ var ts;
536536 function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
537537 var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
538538 var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
539- if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
539+ if (directoryComponents.length > 1 && lastOrUndefined( directoryComponents) === "") {
540540 directoryComponents.length--;
541541 }
542542 for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
@@ -1416,6 +1416,9 @@ var ts;
14161416 Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
14171417 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." },
14181418 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'." },
14191422 Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
14201423 Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
14211424 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;
18441847 }
18451848 collecting = true;
18461849 if (result && result.length) {
1847- result[result.length - 1] .hasTrailingNewLine = true;
1850+ ts.lastOrUndefined(result) .hasTrailingNewLine = true;
18481851 }
18491852 continue;
18501853 case 9:
@@ -1890,7 +1893,7 @@ var ts;
18901893 default:
18911894 if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) {
18921895 if (result && result.length && isLineBreak(ch)) {
1893- result[result.length - 1] .hasTrailingNewLine = true;
1896+ ts.lastOrUndefined(result) .hasTrailingNewLine = true;
18941897 }
18951898 pos++;
18961899 continue;
@@ -3908,7 +3911,7 @@ var ts;
39083911 }
39093912 ts.hasQuestionToken = hasQuestionToken;
39103913 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;
39123915 }
39133916 ts.hasRestParameters = hasRestParameters;
39143917 function isLiteralKind(kind) {
@@ -4336,7 +4339,7 @@ var ts;
43364339 var lineStartsOfS = ts.computeLineStarts(s);
43374340 if (lineStartsOfS.length > 1) {
43384341 lineCount = lineCount + lineStartsOfS.length - 1;
4339- linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1] ;
4342+ linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS) ;
43404343 }
43414344 }
43424345 }
@@ -4405,8 +4408,8 @@ var ts;
44054408 ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
44064409 function shouldEmitToOwnFile(sourceFile, compilerOptions) {
44074410 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") ;
44104413 }
44114414 return false;
44124415 }
@@ -5981,7 +5984,7 @@ var ts;
59815984 templateSpans.pos = getNodePos();
59825985 do {
59835986 templateSpans.push(parseTemplateSpan());
5984- } while (templateSpans[templateSpans.length - 1] .literal.kind === 12);
5987+ } while (ts.lastOrUndefined(templateSpans) .literal.kind === 12);
59855988 templateSpans.end = getNodeEnd();
59865989 template.templateSpans = templateSpans;
59875990 return finishNode(template);
@@ -11125,7 +11128,7 @@ var ts;
1112511128 }
1112611129 function getRestTypeOfSignature(signature) {
1112711130 if (signature.hasRestParameter) {
11128- var type = getTypeOfSymbol(signature.parameters[ signature.parameters.length - 1] );
11131+ var type = getTypeOfSymbol(ts.lastOrUndefined( signature.parameters) );
1112911132 if (type.flags & 4096 && type.target === globalArrayType) {
1113011133 return type.typeArguments[0];
1113111134 }
@@ -13219,7 +13222,7 @@ var ts;
1321913222 }
1322013223 if (indexOfParameter === (func.parameters.length - 1) &&
1322113224 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) );
1322313226 }
1322413227 }
1322513228 }
@@ -14279,9 +14282,9 @@ var ts;
1427914282 links.type = instantiateType(getTypeAtPosition(context, i), mapper);
1428014283 }
1428114284 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) ;
1428314286 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);
1428514288 }
1428614289 }
1428714290 function getReturnTypeFromBody(func, contextualMapper) {
@@ -18660,7 +18663,7 @@ var ts;
1866018663 function checkGrammarBindingElement(node) {
1866118664 if (node.dotDotDotToken) {
1866218665 var elements = node.parent.elements;
18663- if (node !== elements[elements.length - 1] ) {
18666+ if (node !== ts.lastOrUndefined(elements) ) {
1866418667 return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
1866518668 }
1866618669 if (node.name.kind === 152 || node.name.kind === 151) {
@@ -20446,7 +20449,7 @@ var ts;
2044620449 var sourceMapNameIndexMap = {};
2044720450 var sourceMapNameIndices = [];
2044820451 function getSourceMapNameIndex() {
20449- return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
20452+ return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
2045020453 }
2045120454 var lastRecordedSourceMapSpan;
2045220455 var lastEncodedSourceMapSpan = {
@@ -22922,11 +22925,11 @@ var ts;
2292222925 emitNodeWithoutSourceMap(memberName);
2292322926 }
2292422927 }
22925- function getInitializedProperties(node, static ) {
22928+ function getInitializedProperties(node, isStatic ) {
2292622929 var properties = [];
2292722930 for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
2292822931 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) {
2293022933 properties.push(member);
2293122934 }
2293222935 }
@@ -24834,10 +24837,10 @@ var ts;
2483424837 }
2483524838 }
2483624839 function hasDetachedComments(pos) {
24837- return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1] .nodePos === pos;
24840+ return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo) .nodePos === pos;
2483824841 }
2483924842 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);
2484124844 if (detachedCommentsInfo.length - 1) {
2484224845 detachedCommentsInfo.pop();
2484324846 }
@@ -24918,12 +24921,12 @@ var ts;
2491824921 lastComment = comment;
2491924922 });
2492024923 if (detachedComments.length) {
24921- var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1] .end);
24924+ var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments) .end);
2492224925 var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
2492324926 if (nodeLine >= lastCommentLine + 2) {
2492424927 ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
2492524928 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 };
2492724930 if (detachedCommentsInfo) {
2492824931 detachedCommentsInfo.push(currentDetachedCommentInfo);
2492924932 }
@@ -24964,6 +24967,8 @@ var ts;
2496424967 ts.ioReadTime = 0;
2496524968 ts.ioWriteTime = 0;
2496624969 ts.version = "1.5.0";
24970+ var carriageReturnLineFeed = "\r\n";
24971+ var lineFeed = "\n";
2496724972 function findConfigFile(searchPath) {
2496824973 var fileName = "tsconfig.json";
2496924974 while (true) {
@@ -25034,14 +25039,17 @@ var ts;
2503425039 }
2503525040 }
2503625041 }
25042+ var newLine = options.newLine === 0 ? carriageReturnLineFeed :
25043+ options.newLine === 1 ? lineFeed :
25044+ ts.sys.newLine;
2503725045 return {
2503825046 getSourceFile: getSourceFile,
2503925047 getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
2504025048 writeFile: writeFile,
2504125049 getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
2504225050 useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
2504325051 getCanonicalFileName: getCanonicalFileName,
25044- getNewLine: function () { return ts.sys. newLine; }
25052+ getNewLine: function () { return newLine; }
2504525053 };
2504625054 }
2504725055 ts.createCompilerHost = createCompilerHost;
@@ -25526,6 +25534,16 @@ var ts;
2552625534 paramType: ts.Diagnostics.KIND,
2552725535 error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
2552825536 },
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+ },
2552925547 {
2553025548 name: "noEmit",
2553125549 type: "boolean",
0 commit comments