@@ -1532,6 +1532,7 @@ var ts;
1532
1532
TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
1533
1533
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
1534
1534
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
1535
+ TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
1535
1536
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
1536
1537
var TypeFormatFlags = ts.TypeFormatFlags;
1537
1538
(function (SymbolAccessibility) {
@@ -1959,6 +1960,8 @@ var ts;
1959
1960
}
1960
1961
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
1961
1962
function createFileDiagnostic(file, start, length, message) {
1963
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
1964
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
1962
1965
var text = getLocaleSpecificMessage(message.key);
1963
1966
if (arguments.length > 4) {
1964
1967
text = formatStringFromArgs(text, arguments, 4);
@@ -2002,6 +2005,8 @@ var ts;
2002
2005
}
2003
2006
ts.chainDiagnosticMessages = chainDiagnosticMessages;
2004
2007
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
2008
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
2009
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
2005
2010
var code = diagnosticChain.code;
2006
2011
var category = diagnosticChain.category;
2007
2012
var messageText = "";
@@ -2257,6 +2262,7 @@ var ts;
2257
2262
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
2258
2263
})(ts.AssertionLevel || (ts.AssertionLevel = {}));
2259
2264
var AssertionLevel = ts.AssertionLevel;
2265
+ var Debug;
2260
2266
(function (Debug) {
2261
2267
var currentAssertionLevel = 0 /* None */;
2262
2268
function shouldAssert(level) {
@@ -2277,8 +2283,7 @@ var ts;
2277
2283
Debug.assert(false, message);
2278
2284
}
2279
2285
Debug.fail = fail;
2280
- })(ts.Debug || (ts.Debug = {}));
2281
- var Debug = ts.Debug;
2286
+ })(Debug = ts.Debug || (ts.Debug = {}));
2282
2287
})(ts || (ts = {}));
2283
2288
var sys = (function () {
2284
2289
function getWScriptSystem() {
@@ -2544,7 +2549,7 @@ var ts;
2544
2549
function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
2545
2550
node = getErrorSpanForNode(node);
2546
2551
var file = getSourceFileOfNode(node);
2547
- var start = ts.skipTrivia(file.text, node.pos);
2552
+ var start = node.kind === 111 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos);
2548
2553
var length = node.end - start;
2549
2554
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
2550
2555
}
@@ -4735,10 +4740,11 @@ var ts;
4735
4740
parseExpected(88 /* VarKeyword */);
4736
4741
node.declarations = parseVariableDeclarationList(flags, false);
4737
4742
parseSemicolon();
4743
+ finishNode(node);
4738
4744
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
4739
4745
grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
4740
4746
}
4741
- return finishNode( node) ;
4747
+ return node;
4742
4748
}
4743
4749
function parseFunctionDeclaration(pos, flags) {
4744
4750
var node = createNode(167 /* FunctionDeclaration */, pos);
@@ -8476,6 +8482,7 @@ var ts;
8476
8482
var typeCount = 0;
8477
8483
var emptyArray = [];
8478
8484
var emptySymbols = {};
8485
+ var compilerOptions = program.getCompilerOptions();
8479
8486
var checker = {
8480
8487
getProgram: function () { return program; },
8481
8488
getDiagnostics: getDiagnostics,
@@ -9186,7 +9193,7 @@ var ts;
9186
9193
}
9187
9194
return symbol.name;
9188
9195
}
9189
- if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */) )) {
9196
+ if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
9190
9197
var symbolName;
9191
9198
while (symbol) {
9192
9199
var isFirstName = !symbolName;
@@ -9215,17 +9222,25 @@ var ts;
9215
9222
function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
9216
9223
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
9217
9224
}
9218
- function createSingleLineTextWriter() {
9225
+ function createSingleLineTextWriter(maxLength ) {
9219
9226
var result = "";
9220
- return {
9221
- write: function (s) {
9227
+ var overflow = false;
9228
+ function write(s) {
9229
+ if (!overflow) {
9222
9230
result += s;
9223
- },
9231
+ if (result.length > maxLength) {
9232
+ result = result.substr(0, maxLength - 3) + "...";
9233
+ overflow = true;
9234
+ }
9235
+ }
9236
+ }
9237
+ return {
9238
+ write: write,
9224
9239
writeSymbol: function (symbol, enclosingDeclaration, meaning) {
9225
9240
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
9226
9241
},
9227
9242
writeLine: function () {
9228
- result += " ";
9243
+ write( " ") ;
9229
9244
},
9230
9245
increaseIndent: function () {
9231
9246
},
@@ -9237,7 +9252,8 @@ var ts;
9237
9252
};
9238
9253
}
9239
9254
function typeToString(type, enclosingDeclaration, flags) {
9240
- var stringWriter = createSingleLineTextWriter();
9255
+ var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
9256
+ var stringWriter = createSingleLineTextWriter(maxLength);
9241
9257
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
9242
9258
return stringWriter.getText();
9243
9259
}
@@ -9567,7 +9583,7 @@ var ts;
9567
9583
checkImplicitAny(type);
9568
9584
return type;
9569
9585
function checkImplicitAny(type) {
9570
- if (!fullTypeCheck || !program.getCompilerOptions() .noImplicitAny) {
9586
+ if (!fullTypeCheck || !compilerOptions .noImplicitAny) {
9571
9587
return;
9572
9588
}
9573
9589
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@@ -9651,7 +9667,7 @@ var ts;
9651
9667
type = getReturnTypeFromBody(getter);
9652
9668
}
9653
9669
else {
9654
- if (program.getCompilerOptions() .noImplicitAny) {
9670
+ if (compilerOptions .noImplicitAny) {
9655
9671
error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
9656
9672
}
9657
9673
type = anyType;
@@ -11813,7 +11829,7 @@ var ts;
11813
11829
if (stringIndexType) {
11814
11830
return stringIndexType;
11815
11831
}
11816
- if (program.getCompilerOptions() .noImplicitAny && objectType !== anyType) {
11832
+ if (compilerOptions .noImplicitAny && objectType !== anyType) {
11817
11833
error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
11818
11834
}
11819
11835
return anyType;
@@ -11884,32 +11900,21 @@ var ts;
11884
11900
});
11885
11901
return getSignatureInstantiation(signature, getInferredTypes(context));
11886
11902
}
11887
- function inferentiallyTypeExpession(expr, contextualType, contextualMapper) {
11888
- var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
11889
- var signature = getSingleCallSignature(type);
11890
- if (signature && signature.typeParameters) {
11891
- var contextualSignature = getSingleCallSignature(contextualType);
11892
- if (contextualSignature && !contextualSignature.typeParameters) {
11893
- type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
11894
- }
11895
- }
11896
- return type;
11897
- }
11898
11903
function inferTypeArguments(signature, args, excludeArgument) {
11899
11904
var typeParameters = signature.typeParameters;
11900
11905
var context = createInferenceContext(typeParameters);
11901
11906
var mapper = createInferenceMapper(context);
11902
11907
for (var i = 0; i < args.length; i++) {
11903
11908
if (!excludeArgument || excludeArgument[i] === undefined) {
11904
11909
var parameterType = getTypeAtPosition(signature, i);
11905
- inferTypes(context, inferentiallyTypeExpession (args[i], parameterType, mapper), parameterType);
11910
+ inferTypes(context, checkExpressionWithContextualType (args[i], parameterType, mapper), parameterType);
11906
11911
}
11907
11912
}
11908
11913
if (excludeArgument) {
11909
11914
for (var i = 0; i < args.length; i++) {
11910
11915
if (excludeArgument[i] === false) {
11911
11916
var parameterType = getTypeAtPosition(signature, i);
11912
- inferTypes(context, inferentiallyTypeExpession (args[i], parameterType, mapper), parameterType);
11917
+ inferTypes(context, checkExpressionWithContextualType (args[i], parameterType, mapper), parameterType);
11913
11918
}
11914
11919
}
11915
11920
}
@@ -12067,7 +12072,7 @@ var ts;
12067
12072
if (node.kind === 133 /* NewExpression */) {
12068
12073
var declaration = signature.declaration;
12069
12074
if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
12070
- if (program.getCompilerOptions() .noImplicitAny) {
12075
+ if (compilerOptions .noImplicitAny) {
12071
12076
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
12072
12077
}
12073
12078
return anyType;
@@ -12106,7 +12111,7 @@ var ts;
12106
12111
if (func.body.kind !== 168 /* FunctionBlock */) {
12107
12112
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
12108
12113
var widenedType = getWidenedType(unwidenedType);
12109
- if (fullTypeCheck && program.getCompilerOptions() .noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
12114
+ if (fullTypeCheck && compilerOptions .noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
12110
12115
error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
12111
12116
}
12112
12117
return widenedType;
@@ -12119,7 +12124,7 @@ var ts;
12119
12124
return unknownType;
12120
12125
}
12121
12126
var widenedType = getWidenedType(commonType);
12122
- if (fullTypeCheck && program.getCompilerOptions() .noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
12127
+ if (fullTypeCheck && compilerOptions .noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
12123
12128
var typeName = typeToString(widenedType);
12124
12129
if (func.name) {
12125
12130
error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.identifierToString(func.name), typeName);
@@ -12455,6 +12460,22 @@ var ts;
12455
12460
return result;
12456
12461
}
12457
12462
function checkExpression(node, contextualMapper) {
12463
+ var type = checkExpressionNode(node, contextualMapper);
12464
+ if (contextualMapper && contextualMapper !== identityMapper) {
12465
+ var signature = getSingleCallSignature(type);
12466
+ if (signature && signature.typeParameters) {
12467
+ var contextualType = getContextualType(node);
12468
+ if (contextualType) {
12469
+ var contextualSignature = getSingleCallSignature(contextualType);
12470
+ if (contextualSignature && !contextualSignature.typeParameters) {
12471
+ type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
12472
+ }
12473
+ }
12474
+ }
12475
+ }
12476
+ return type;
12477
+ }
12478
+ function checkExpressionNode(node, contextualMapper) {
12458
12479
switch (node.kind) {
12459
12480
case 55 /* Identifier */:
12460
12481
return checkIdentifier(node);
@@ -12565,7 +12586,7 @@ var ts;
12565
12586
checkCollisionWithCapturedThisVariable(node, node.name);
12566
12587
checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
12567
12588
checkCollisionWithArgumentsInGeneratedCode(node);
12568
- if (program.getCompilerOptions() .noImplicitAny && !node.type) {
12589
+ if (compilerOptions .noImplicitAny && !node.type) {
12569
12590
switch (node.kind) {
12570
12591
case 121 /* ConstructSignature */:
12571
12592
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -12976,7 +12997,7 @@ var ts;
12976
12997
if (node.type && !isAccessor(node.kind)) {
12977
12998
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
12978
12999
}
12979
- if (fullTypeCheck && program.getCompilerOptions() .noImplicitAny && !node.body && !node.type) {
13000
+ if (fullTypeCheck && compilerOptions .noImplicitAny && !node.body && !node.type) {
12980
13001
if (!isPrivateWithinAmbient(node)) {
12981
13002
var typeName = typeToString(anyType);
12982
13003
if (node.name) {
@@ -14273,7 +14294,7 @@ var ts;
14273
14294
return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
14274
14295
}
14275
14296
function shouldEmitDeclarations() {
14276
- return program.getCompilerOptions() .declaration && !program.getDiagnostics().length && !getDiagnostics().length;
14297
+ return compilerOptions .declaration && !program.getDiagnostics().length && !getDiagnostics().length;
14277
14298
}
14278
14299
function isReferencedImportDeclaration(node) {
14279
14300
var symbol = getSymbolOfNode(node);
0 commit comments