Skip to content

Commit bc36f8c

Browse files
committed
Apparent members for type params constrained by any
1 parent cd97270 commit bc36f8c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9927,9 +9927,9 @@ namespace ts {
99279927
}
99289928

99299929
const apparentType = getApparentType(getWidenedType(type));
9930-
if (apparentType === unknownType) {
9931-
// handle cases when type is Type parameter with invalid constraint
9932-
return unknownType;
9930+
if (apparentType === unknownType || (type.flags & TypeFlags.TypeParameter && isTypeAny(apparentType))) {
9931+
// handle cases when type is Type parameter with invalid or any constraint
9932+
return apparentType;
99339933
}
99349934
const prop = getPropertyOfType(apparentType, right.text);
99359935
if (!prop) {
@@ -11120,7 +11120,9 @@ namespace ts {
1112011120
// types are provided for the argument expressions, and the result is always of type Any.
1112111121
// We exclude union types because we may have a union of function types that happen to have
1112211122
// no common signatures.
11123-
if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
11123+
if (isTypeAny(funcType) ||
11124+
(isTypeAny(apparentType) && funcType.flags & TypeFlags.TypeParameter) ||
11125+
(!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
1112411126
// The unknownType indicates that an error already occurred (and was reported). No
1112511127
// need to report another error in this case.
1112611128
if (funcType !== unknownType && node.typeArguments) {

0 commit comments

Comments
 (0)