@@ -3346,7 +3346,13 @@ namespace ts {
33463346 // Otherwise, fall back to 'any'.
33473347 else {
33483348 if (compilerOptions.noImplicitAny) {
3349- error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol));
3349+ if (setter) {
3350+ error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
3351+ }
3352+ else {
3353+ Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
3354+ error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
3355+ }
33503356 }
33513357 type = anyType;
33523358 }
@@ -11960,18 +11966,12 @@ namespace ts {
1196011966 // Function interface, since they have none by default. This is a bit of a leap of faith
1196111967 // that the user will not add any.
1196211968 const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
11963-
1196411969 const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
11965- // TS 1.0 spec: 4.12
11966- // If FuncExpr is of type Any, or of an object type that has no call or construct signatures
11967- // but is a subtype of the Function interface, the call is an untyped function call. In an
11968- // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual
11970+
11971+ // TS 1.0 Spec: 4.12
11972+ // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual
1196911973 // types are provided for the argument expressions, and the result is always of type Any.
11970- // We exclude union types because we may have a union of function types that happen to have
11971- // no common signatures.
11972- if (isTypeAny(funcType) ||
11973- (isTypeAny(apparentType) && funcType.flags & TypeFlags.TypeParameter) ||
11974- (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
11974+ if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) {
1197511975 // The unknownType indicates that an error already occurred (and was reported). No
1197611976 // need to report another error in this case.
1197711977 if (funcType !== unknownType && node.typeArguments) {
@@ -11994,6 +11994,29 @@ namespace ts {
1199411994 return resolveCall(node, callSignatures, candidatesOutArray);
1199511995 }
1199611996
11997+ /**
11998+ * TS 1.0 spec: 4.12
11999+ * If FuncExpr is of type Any, or of an object type that has no call or construct signatures
12000+ * but is a subtype of the Function interface, the call is an untyped function call.
12001+ */
12002+ function isUntypedFunctionCall(funcType: Type, apparentFuncType: Type, numCallSignatures: number, numConstructSignatures: number) {
12003+ if (isTypeAny(funcType)) {
12004+ return true;
12005+ }
12006+ if (isTypeAny(apparentFuncType) && funcType.flags & TypeFlags.TypeParameter) {
12007+ return true;
12008+ }
12009+ if (!numCallSignatures && !numConstructSignatures) {
12010+ // We exclude union types because we may have a union of function types that happen to have
12011+ // no common signatures.
12012+ if (funcType.flags & TypeFlags.Union) {
12013+ return false;
12014+ }
12015+ return isTypeAssignableTo(funcType, globalFunctionType);
12016+ }
12017+ return false;
12018+ }
12019+
1199712020 function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature {
1199812021 if (node.arguments && languageVersion < ScriptTarget.ES5) {
1199912022 const spreadIndex = getSpreadArgumentIndex(node.arguments);
@@ -12119,8 +12142,9 @@ namespace ts {
1211912142 }
1212012143
1212112144 const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
12145+ const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
1212212146
12123- if (isTypeAny (tagType) || (! callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType) )) {
12147+ if (isUntypedFunctionCall (tagType, apparentType, callSignatures.length, constructSignatures.length )) {
1212412148 return resolveUntypedCall(node);
1212512149 }
1212612150
@@ -12165,7 +12189,8 @@ namespace ts {
1216512189 }
1216612190
1216712191 const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
12168- if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
12192+ const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
12193+ if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) {
1216912194 return resolveUntypedCall(node);
1217012195 }
1217112196
0 commit comments