Skip to content

Commit abf18c5

Browse files
committed
Merge branch 'release-1.5'
2 parents 343a923 + b165b14 commit abf18c5

33 files changed

+353
-40
lines changed

Jakefile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ var harnessSources = [
129129
"services/preProcessFile.ts",
130130
"services/patternMatcher.ts",
131131
"versionCache.ts",
132-
"convertToBase64.ts"
132+
"convertToBase64.ts",
133+
"transpile.ts"
133134
].map(function (f) {
134135
return path.join(unittestsDirectory, f);
135136
})).concat([

bin/tsc.js

+25-5
Original file line numberDiff line numberDiff line change
@@ -4884,6 +4884,21 @@ var ts;
48844884
return result;
48854885
}
48864886
ts.convertToBase64 = convertToBase64;
4887+
var carriageReturnLineFeed = "\r\n";
4888+
var lineFeed = "\n";
4889+
function getNewLineCharacter(options) {
4890+
if (options.newLine === 0) {
4891+
return carriageReturnLineFeed;
4892+
}
4893+
else if (options.newLine === 1) {
4894+
return lineFeed;
4895+
}
4896+
else if (ts.sys) {
4897+
return ts.sys.newLine;
4898+
}
4899+
return carriageReturnLineFeed;
4900+
}
4901+
ts.getNewLineCharacter = getNewLineCharacter;
48874902
})(ts || (ts = {}));
48884903
var ts;
48894904
(function (ts) {
@@ -15409,6 +15424,9 @@ var ts;
1540915424
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
1541015425
}
1541115426
if (node.body) {
15427+
if (!node.type) {
15428+
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
15429+
}
1541215430
if (node.body.kind === 180) {
1541315431
checkSourceElement(node.body);
1541415432
}
@@ -26055,8 +26073,6 @@ var ts;
2605526073
ts.ioReadTime = 0;
2605626074
ts.ioWriteTime = 0;
2605726075
ts.version = "1.5.3";
26058-
var carriageReturnLineFeed = "\r\n";
26059-
var lineFeed = "\n";
2606026076
function findConfigFile(searchPath) {
2606126077
var fileName = "tsconfig.json";
2606226078
while (true) {
@@ -26127,9 +26143,7 @@ var ts;
2612726143
}
2612826144
}
2612926145
}
26130-
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
26131-
options.newLine === 1 ? lineFeed :
26132-
ts.sys.newLine;
26146+
var newLine = ts.getNewLineCharacter(options);
2613326147
return {
2613426148
getSourceFile: getSourceFile,
2613526149
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@@ -26197,6 +26211,7 @@ var ts;
2619726211
getGlobalDiagnostics: getGlobalDiagnostics,
2619826212
getSemanticDiagnostics: getSemanticDiagnostics,
2619926213
getDeclarationDiagnostics: getDeclarationDiagnostics,
26214+
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
2620026215
getTypeChecker: getTypeChecker,
2620126216
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
2620226217
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@@ -26277,6 +26292,11 @@ var ts;
2627726292
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
2627826293
}
2627926294
}
26295+
function getCompilerOptionsDiagnostics() {
26296+
var allDiagnostics = [];
26297+
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
26298+
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
26299+
}
2628026300
function getGlobalDiagnostics() {
2628126301
var typeChecker = getDiagnosticsProducingTypeChecker();
2628226302
var allDiagnostics = [];

bin/tsserver.js

+30-7
Original file line numberDiff line numberDiff line change
@@ -4759,6 +4759,21 @@ var ts;
47594759
return result;
47604760
}
47614761
ts.convertToBase64 = convertToBase64;
4762+
var carriageReturnLineFeed = "\r\n";
4763+
var lineFeed = "\n";
4764+
function getNewLineCharacter(options) {
4765+
if (options.newLine === 0) {
4766+
return carriageReturnLineFeed;
4767+
}
4768+
else if (options.newLine === 1) {
4769+
return lineFeed;
4770+
}
4771+
else if (ts.sys) {
4772+
return ts.sys.newLine;
4773+
}
4774+
return carriageReturnLineFeed;
4775+
}
4776+
ts.getNewLineCharacter = getNewLineCharacter;
47624777
})(ts || (ts = {}));
47634778
var ts;
47644779
(function (ts) {
@@ -15799,6 +15814,9 @@ var ts;
1579915814
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
1580015815
}
1580115816
if (node.body) {
15817+
if (!node.type) {
15818+
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
15819+
}
1580215820
if (node.body.kind === 180) {
1580315821
checkSourceElement(node.body);
1580415822
}
@@ -26445,8 +26463,6 @@ var ts;
2644526463
ts.ioReadTime = 0;
2644626464
ts.ioWriteTime = 0;
2644726465
ts.version = "1.5.3";
26448-
var carriageReturnLineFeed = "\r\n";
26449-
var lineFeed = "\n";
2645026466
function findConfigFile(searchPath) {
2645126467
var fileName = "tsconfig.json";
2645226468
while (true) {
@@ -26517,9 +26533,7 @@ var ts;
2651726533
}
2651826534
}
2651926535
}
26520-
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
26521-
options.newLine === 1 ? lineFeed :
26522-
ts.sys.newLine;
26536+
var newLine = ts.getNewLineCharacter(options);
2652326537
return {
2652426538
getSourceFile: getSourceFile,
2652526539
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@@ -26587,6 +26601,7 @@ var ts;
2658726601
getGlobalDiagnostics: getGlobalDiagnostics,
2658826602
getSemanticDiagnostics: getSemanticDiagnostics,
2658926603
getDeclarationDiagnostics: getDeclarationDiagnostics,
26604+
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
2659026605
getTypeChecker: getTypeChecker,
2659126606
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
2659226607
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@@ -26667,6 +26682,11 @@ var ts;
2666726682
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
2666826683
}
2666926684
}
26685+
function getCompilerOptionsDiagnostics() {
26686+
var allDiagnostics = [];
26687+
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
26688+
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
26689+
}
2667026690
function getGlobalDiagnostics() {
2667126691
var typeChecker = getDiagnosticsProducingTypeChecker();
2667226692
var allDiagnostics = [];
@@ -32389,11 +32409,14 @@ var ts;
3238932409
var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
3239032410
options.isolatedModules = true;
3239132411
options.allowNonTsExtensions = true;
32412+
options.noLib = true;
32413+
options.noResolve = true;
3239232414
var inputFileName = fileName || "module.ts";
3239332415
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
3239432416
if (diagnostics && sourceFile.parseDiagnostics) {
3239532417
diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
3239632418
}
32419+
var newLine = ts.getNewLineCharacter(options);
3239732420
var outputText;
3239832421
var compilerHost = {
3239932422
getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; },
@@ -32405,11 +32428,11 @@ var ts;
3240532428
useCaseSensitiveFileNames: function () { return false; },
3240632429
getCanonicalFileName: function (fileName) { return fileName; },
3240732430
getCurrentDirectory: function () { return ""; },
32408-
getNewLine: function () { return (ts.sys && ts.sys.newLine) || "\r\n"; }
32431+
getNewLine: function () { return newLine; }
3240932432
};
3241032433
var program = ts.createProgram([inputFileName], options, compilerHost);
3241132434
if (diagnostics) {
32412-
diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics());
32435+
diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics());
3241332436
}
3241432437
program.emit();
3241532438
ts.Debug.assert(outputText !== undefined, "Output generation failed");

bin/typescript.js

+41-7
Original file line numberDiff line numberDiff line change
@@ -6159,6 +6159,21 @@ var ts;
61596159
return result;
61606160
}
61616161
ts.convertToBase64 = convertToBase64;
6162+
var carriageReturnLineFeed = "\r\n";
6163+
var lineFeed = "\n";
6164+
function getNewLineCharacter(options) {
6165+
if (options.newLine === 0 /* CarriageReturnLineFeed */) {
6166+
return carriageReturnLineFeed;
6167+
}
6168+
else if (options.newLine === 1 /* LineFeed */) {
6169+
return lineFeed;
6170+
}
6171+
else if (ts.sys) {
6172+
return ts.sys.newLine;
6173+
}
6174+
return carriageReturnLineFeed;
6175+
}
6176+
ts.getNewLineCharacter = getNewLineCharacter;
61626177
})(ts || (ts = {}));
61636178
var ts;
61646179
(function (ts) {
@@ -18778,6 +18793,14 @@ var ts;
1877818793
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
1877918794
}
1878018795
if (node.body) {
18796+
if (!node.type) {
18797+
// There are some checks that are only performed in getReturnTypeFromBody, that may produce errors
18798+
// we need. An example is the noImplicitAny errors resulting from widening the return expression
18799+
// of a function. Because checking of function expression bodies is deferred, there was never an
18800+
// appropriate time to do this during the main walk of the file (see the comment at the top of
18801+
// checkFunctionExpressionBodies). So it must be done now.
18802+
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
18803+
}
1878118804
if (node.body.kind === 180 /* Block */) {
1878218805
checkSourceElement(node.body);
1878318806
}
@@ -30945,8 +30968,6 @@ var ts;
3094530968
/* @internal */ ts.ioWriteTime = 0;
3094630969
/** The version of the TypeScript compiler release */
3094730970
ts.version = "1.5.3";
30948-
var carriageReturnLineFeed = "\r\n";
30949-
var lineFeed = "\n";
3095030971
function findConfigFile(searchPath) {
3095130972
var fileName = "tsconfig.json";
3095230973
while (true) {
@@ -31020,9 +31041,7 @@ var ts;
3102031041
}
3102131042
}
3102231043
}
31023-
var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
31024-
options.newLine === 1 /* LineFeed */ ? lineFeed :
31025-
ts.sys.newLine;
31044+
var newLine = ts.getNewLineCharacter(options);
3102631045
return {
3102731046
getSourceFile: getSourceFile,
3102831047
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@@ -31090,6 +31109,7 @@ var ts;
3109031109
getGlobalDiagnostics: getGlobalDiagnostics,
3109131110
getSemanticDiagnostics: getSemanticDiagnostics,
3109231111
getDeclarationDiagnostics: getDeclarationDiagnostics,
31112+
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
3109331113
getTypeChecker: getTypeChecker,
3109431114
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
3109531115
getCommonSourceDirectory: function () { return commonSourceDirectory; },
@@ -31181,6 +31201,11 @@ var ts;
3118131201
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
3118231202
}
3118331203
}
31204+
function getCompilerOptionsDiagnostics() {
31205+
var allDiagnostics = [];
31206+
ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
31207+
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
31208+
}
3118431209
function getGlobalDiagnostics() {
3118531210
var typeChecker = getDiagnosticsProducingTypeChecker();
3118631211
var allDiagnostics = [];
@@ -38000,19 +38025,28 @@ var ts;
3800038025
* Extra compiler options that will unconditionally be used bu this function are:
3800138026
* - isolatedModules = true
3800238027
* - allowNonTsExtensions = true
38028+
* - noLib = true
38029+
* - noResolve = true
3800338030
*/
3800438031
function transpile(input, compilerOptions, fileName, diagnostics) {
3800538032
var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions();
3800638033
options.isolatedModules = true;
3800738034
// Filename can be non-ts file.
3800838035
options.allowNonTsExtensions = true;
38036+
// We are not returning a sourceFile for lib file when asked by the program,
38037+
// so pass --noLib to avoid reporting a file not found error.
38038+
options.noLib = true;
38039+
// We are not doing a full typecheck, we are not resolving the whole context,
38040+
// so pass --noResolve to avoid reporting missing file errors.
38041+
options.noResolve = true;
3800938042
// Parse
3801038043
var inputFileName = fileName || "module.ts";
3801138044
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
3801238045
// Store syntactic diagnostics
3801338046
if (diagnostics && sourceFile.parseDiagnostics) {
3801438047
diagnostics.push.apply(diagnostics, sourceFile.parseDiagnostics);
3801538048
}
38049+
var newLine = ts.getNewLineCharacter(options);
3801638050
// Output
3801738051
var outputText;
3801838052
// Create a compilerHost object to allow the compiler to read and write files
@@ -38026,11 +38060,11 @@ var ts;
3802638060
useCaseSensitiveFileNames: function () { return false; },
3802738061
getCanonicalFileName: function (fileName) { return fileName; },
3802838062
getCurrentDirectory: function () { return ""; },
38029-
getNewLine: function () { return (ts.sys && ts.sys.newLine) || "\r\n"; }
38063+
getNewLine: function () { return newLine; }
3803038064
};
3803138065
var program = ts.createProgram([inputFileName], options, compilerHost);
3803238066
if (diagnostics) {
38033-
diagnostics.push.apply(diagnostics, program.getGlobalDiagnostics());
38067+
diagnostics.push.apply(diagnostics, program.getCompilerOptionsDiagnostics());
3803438068
}
3803538069
// Emit
3803638070
program.emit();

0 commit comments

Comments
 (0)