@@ -1532,6 +1532,7 @@ var ts;
15321532 TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
15331533 TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
15341534 TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
1535+ TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
15351536 })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
15361537 var TypeFormatFlags = ts.TypeFormatFlags;
15371538 (function (SymbolAccessibility) {
@@ -1959,6 +1960,8 @@ var ts;
19591960 }
19601961 ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
19611962 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);
19621965 var text = getLocaleSpecificMessage(message.key);
19631966 if (arguments.length > 4) {
19641967 text = formatStringFromArgs(text, arguments, 4);
@@ -2002,6 +2005,8 @@ var ts;
20022005 }
20032006 ts.chainDiagnosticMessages = chainDiagnosticMessages;
20042007 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);
20052010 var code = diagnosticChain.code;
20062011 var category = diagnosticChain.category;
20072012 var messageText = "";
@@ -2257,6 +2262,7 @@ var ts;
22572262 AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
22582263 })(ts.AssertionLevel || (ts.AssertionLevel = {}));
22592264 var AssertionLevel = ts.AssertionLevel;
2265+ var Debug;
22602266 (function (Debug) {
22612267 var currentAssertionLevel = 0 /* None */;
22622268 function shouldAssert(level) {
@@ -2277,8 +2283,7 @@ var ts;
22772283 Debug.assert(false, message);
22782284 }
22792285 Debug.fail = fail;
2280- })(ts.Debug || (ts.Debug = {}));
2281- var Debug = ts.Debug;
2286+ })(Debug = ts.Debug || (ts.Debug = {}));
22822287})(ts || (ts = {}));
22832288var sys = (function () {
22842289 function getWScriptSystem() {
@@ -2544,7 +2549,7 @@ var ts;
25442549 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
25452550 node = getErrorSpanForNode(node);
25462551 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);
25482553 var length = node.end - start;
25492554 return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
25502555 }
@@ -4735,10 +4740,11 @@ var ts;
47354740 parseExpected(88 /* VarKeyword */);
47364741 node.declarations = parseVariableDeclarationList(flags, false);
47374742 parseSemicolon();
4743+ finishNode(node);
47384744 if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
47394745 grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
47404746 }
4741- return finishNode( node) ;
4747+ return node;
47424748 }
47434749 function parseFunctionDeclaration(pos, flags) {
47444750 var node = createNode(167 /* FunctionDeclaration */, pos);
@@ -8476,6 +8482,7 @@ var ts;
84768482 var typeCount = 0;
84778483 var emptyArray = [];
84788484 var emptySymbols = {};
8485+ var compilerOptions = program.getCompilerOptions();
84798486 var checker = {
84808487 getProgram: function () { return program; },
84818488 getDiagnostics: getDiagnostics,
@@ -9186,7 +9193,7 @@ var ts;
91869193 }
91879194 return symbol.name;
91889195 }
9189- if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */) )) {
9196+ if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
91909197 var symbolName;
91919198 while (symbol) {
91929199 var isFirstName = !symbolName;
@@ -9215,17 +9222,25 @@ var ts;
92159222 function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
92169223 writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
92179224 }
9218- function createSingleLineTextWriter() {
9225+ function createSingleLineTextWriter(maxLength ) {
92199226 var result = "";
9220- return {
9221- write: function (s) {
9227+ var overflow = false;
9228+ function write(s) {
9229+ if (!overflow) {
92229230 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,
92249239 writeSymbol: function (symbol, enclosingDeclaration, meaning) {
92259240 writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
92269241 },
92279242 writeLine: function () {
9228- result += " ";
9243+ write( " ") ;
92299244 },
92309245 increaseIndent: function () {
92319246 },
@@ -9237,7 +9252,8 @@ var ts;
92379252 };
92389253 }
92399254 function typeToString(type, enclosingDeclaration, flags) {
9240- var stringWriter = createSingleLineTextWriter();
9255+ var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
9256+ var stringWriter = createSingleLineTextWriter(maxLength);
92419257 writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
92429258 return stringWriter.getText();
92439259 }
@@ -9567,7 +9583,7 @@ var ts;
95679583 checkImplicitAny(type);
95689584 return type;
95699585 function checkImplicitAny(type) {
9570- if (!fullTypeCheck || !program.getCompilerOptions() .noImplicitAny) {
9586+ if (!fullTypeCheck || !compilerOptions .noImplicitAny) {
95719587 return;
95729588 }
95739589 if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@@ -9651,7 +9667,7 @@ var ts;
96519667 type = getReturnTypeFromBody(getter);
96529668 }
96539669 else {
9654- if (program.getCompilerOptions() .noImplicitAny) {
9670+ if (compilerOptions .noImplicitAny) {
96559671 error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
96569672 }
96579673 type = anyType;
@@ -11813,7 +11829,7 @@ var ts;
1181311829 if (stringIndexType) {
1181411830 return stringIndexType;
1181511831 }
11816- if (program.getCompilerOptions() .noImplicitAny && objectType !== anyType) {
11832+ if (compilerOptions .noImplicitAny && objectType !== anyType) {
1181711833 error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
1181811834 }
1181911835 return anyType;
@@ -11884,32 +11900,21 @@ var ts;
1188411900 });
1188511901 return getSignatureInstantiation(signature, getInferredTypes(context));
1188611902 }
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- }
1189811903 function inferTypeArguments(signature, args, excludeArgument) {
1189911904 var typeParameters = signature.typeParameters;
1190011905 var context = createInferenceContext(typeParameters);
1190111906 var mapper = createInferenceMapper(context);
1190211907 for (var i = 0; i < args.length; i++) {
1190311908 if (!excludeArgument || excludeArgument[i] === undefined) {
1190411909 var parameterType = getTypeAtPosition(signature, i);
11905- inferTypes(context, inferentiallyTypeExpession (args[i], parameterType, mapper), parameterType);
11910+ inferTypes(context, checkExpressionWithContextualType (args[i], parameterType, mapper), parameterType);
1190611911 }
1190711912 }
1190811913 if (excludeArgument) {
1190911914 for (var i = 0; i < args.length; i++) {
1191011915 if (excludeArgument[i] === false) {
1191111916 var parameterType = getTypeAtPosition(signature, i);
11912- inferTypes(context, inferentiallyTypeExpession (args[i], parameterType, mapper), parameterType);
11917+ inferTypes(context, checkExpressionWithContextualType (args[i], parameterType, mapper), parameterType);
1191311918 }
1191411919 }
1191511920 }
@@ -12067,7 +12072,7 @@ var ts;
1206712072 if (node.kind === 133 /* NewExpression */) {
1206812073 var declaration = signature.declaration;
1206912074 if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
12070- if (program.getCompilerOptions() .noImplicitAny) {
12075+ if (compilerOptions .noImplicitAny) {
1207112076 error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
1207212077 }
1207312078 return anyType;
@@ -12106,7 +12111,7 @@ var ts;
1210612111 if (func.body.kind !== 168 /* FunctionBlock */) {
1210712112 var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
1210812113 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) {
1211012115 error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
1211112116 }
1211212117 return widenedType;
@@ -12119,7 +12124,7 @@ var ts;
1211912124 return unknownType;
1212012125 }
1212112126 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) {
1212312128 var typeName = typeToString(widenedType);
1212412129 if (func.name) {
1212512130 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;
1245512460 return result;
1245612461 }
1245712462 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) {
1245812479 switch (node.kind) {
1245912480 case 55 /* Identifier */:
1246012481 return checkIdentifier(node);
@@ -12565,7 +12586,7 @@ var ts;
1256512586 checkCollisionWithCapturedThisVariable(node, node.name);
1256612587 checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
1256712588 checkCollisionWithArgumentsInGeneratedCode(node);
12568- if (program.getCompilerOptions() .noImplicitAny && !node.type) {
12589+ if (compilerOptions .noImplicitAny && !node.type) {
1256912590 switch (node.kind) {
1257012591 case 121 /* ConstructSignature */:
1257112592 error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -12976,7 +12997,7 @@ var ts;
1297612997 if (node.type && !isAccessor(node.kind)) {
1297712998 checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
1297812999 }
12979- if (fullTypeCheck && program.getCompilerOptions() .noImplicitAny && !node.body && !node.type) {
13000+ if (fullTypeCheck && compilerOptions .noImplicitAny && !node.body && !node.type) {
1298013001 if (!isPrivateWithinAmbient(node)) {
1298113002 var typeName = typeToString(anyType);
1298213003 if (node.name) {
@@ -14273,7 +14294,7 @@ var ts;
1427314294 return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
1427414295 }
1427514296 function shouldEmitDeclarations() {
14276- return program.getCompilerOptions() .declaration && !program.getDiagnostics().length && !getDiagnostics().length;
14297+ return compilerOptions .declaration && !program.getDiagnostics().length && !getDiagnostics().length;
1427714298 }
1427814299 function isReferencedImportDeclaration(node) {
1427914300 var symbol = getSymbolOfNode(node);
0 commit comments