@@ -5793,6 +5793,21 @@ var ts;
57935793 return result;
57945794 }
57955795 ts.convertToBase64 = convertToBase64;
5796+ var carriageReturnLineFeed = "\r\n";
5797+ var lineFeed = "\n";
5798+ function getNewLineCharacter(options) {
5799+ if (options.newLine === 0 /* CarriageReturnLineFeed */) {
5800+ return carriageReturnLineFeed;
5801+ }
5802+ else if (options.newLine === 1 /* LineFeed */) {
5803+ return lineFeed;
5804+ }
5805+ else if (ts.sys) {
5806+ return ts.sys.newLine;
5807+ }
5808+ return carriageReturnLineFeed;
5809+ }
5810+ ts.getNewLineCharacter = getNewLineCharacter;
57965811})(ts || (ts = {}));
57975812var ts;
57985813(function (ts) {
@@ -17596,6 +17611,14 @@ var ts;
1759617611 checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
1759717612 }
1759817613 if (node.body) {
17614+ if (!node.type) {
17615+ // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors
17616+ // we need. An example is the noImplicitAny errors resulting from widening the return expression
17617+ // of a function. Because checking of function expression bodies is deferred, there was never an
17618+ // appropriate time to do this during the main walk of the file (see the comment at the top of
17619+ // checkFunctionExpressionBodies). So it must be done now.
17620+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
17621+ }
1759917622 if (node.body.kind === 180 /* Block */) {
1760017623 checkSourceElement(node.body);
1760117624 }
@@ -29658,8 +29681,6 @@ var ts;
2965829681 /* @internal */ ts.ioWriteTime = 0;
2965929682 /** The version of the TypeScript compiler release */
2966029683 ts.version = "1.5.3";
29661- var carriageReturnLineFeed = "\r\n";
29662- var lineFeed = "\n";
2966329684 function findConfigFile(searchPath) {
2966429685 var fileName = "tsconfig.json";
2966529686 while (true) {
@@ -29733,9 +29754,7 @@ var ts;
2973329754 }
2973429755 }
2973529756 }
29736- var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
29737- options.newLine === 1 /* LineFeed */ ? lineFeed :
29738- ts.sys.newLine;
29757+ var newLine = ts.getNewLineCharacter(options);
2973929758 return {
2974029759 getSourceFile: getSourceFile,
2974129760 getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@@ -29803,6 +29822,7 @@ var ts;
2980329822 getGlobalDiagnostics: getGlobalDiagnostics,
2980429823 getSemanticDiagnostics: getSemanticDiagnostics,
2980529824 getDeclarationDiagnostics: getDeclarationDiagnostics,
29825+ getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
2980629826 getTypeChecker: getTypeChecker,
2980729827 getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
2980829828 getCommonSourceDirectory: function () { return commonSourceDirectory; },
@@ -29894,6 +29914,11 @@ var ts;
2989429914 return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
2989529915 }
2989629916 }
29917+ function getCompilerOptionsDiagnostics() {
29918+ var allDiagnostics = [];
29919+ ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
29920+ return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
29921+ }
2989729922 function getGlobalDiagnostics() {
2989829923 var typeChecker = getDiagnosticsProducingTypeChecker();
2989929924 var allDiagnostics = [];
@@ -36695,19 +36720,28 @@ var ts;
3669536720 * Extra compiler options that will unconditionally be used bu this function are:
3669636721 * - isolatedModules = true
3669736722 * - allowNonTsExtensions = true
36723+ * - noLib = true
36724+ * - noResolve = true
3669836725 */
3669936726 function transpile(input, compilerOptions, fileName, diagnostics) {
3670036727 var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
3670136728 options.isolatedModules = true;
3670236729 // Filename can be non-ts file.
3670336730 options.allowNonTsExtensions = true;
36731+ // We are not returning a sourceFile for lib file when asked by the program,
36732+ // so pass --noLib to avoid reporting a file not found error.
36733+ options.noLib = true;
36734+ // We are not doing a full typecheck, we are not resolving the whole context,
36735+ // so pass --noResolve to avoid reporting missing file errors.
36736+ options.noResolve = true;
3670436737 // Parse
3670536738 var inputFileName = fileName || "module.ts";
3670636739 var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
3670736740 // Store syntactic diagnostics
3670836741 if (diagnostics && sourceFile.parseDiagnostics) {
3670936742 diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
3671036743 }
36744+ var newLine = ts.getNewLineCharacter(options);
3671136745 // Output
3671236746 var outputText;
3671336747 // Create a compilerHost object to allow the compiler to read and write files
@@ -36721,11 +36755,11 @@ var ts;
3672136755 useCaseSensitiveFileNames: function () { return false; },
3672236756 getCanonicalFileName: function (fileName) { return fileName; },
3672336757 getCurrentDirectory: function () { return ""; },
36724- getNewLine: function () { return (ts.sys && ts.sys. newLine) || "\r\n" ; }
36758+ getNewLine: function () { return newLine; }
3672536759 };
3672636760 var program = ts.createProgram([inputFileName], options, compilerHost);
3672736761 if (diagnostics) {
36728- diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics ());
36762+ diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics ());
3672936763 }
3673036764 // Emit
3673136765 program.emit();
@@ -37328,12 +37362,16 @@ var ts;
3732837362 }
3732937363 }
3733037364 }
37365+ // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
37366+ // It needs to be cleared to allow all collected snapshots to be released
37367+ hostCache = undefined;
3733137368 program = newProgram;
3733237369 // Make sure all the nodes in the program are both bound, and have their parent
3733337370 // pointers set property.
3733437371 program.getTypeChecker();
3733537372 return;
3733637373 function getOrCreateSourceFile(fileName) {
37374+ ts.Debug.assert(hostCache !== undefined);
3733737375 // The program is asking for this file, check first if the host can locate it.
3733837376 // If the host can not locate the file, then it does not exist. return undefined
3733937377 // to the program to allow reporting of errors for missing files.
0 commit comments