@@ -4370,8 +4370,7 @@ namespace ts {
4370
4370
case TypeSystemPropertyName.ResolvedReturnType:
4371
4371
return !!(<Signature>target).resolvedReturnType;
4372
4372
case TypeSystemPropertyName.ImmediateBaseConstraint:
4373
- const bc = (<Type>target).immediateBaseConstraint;
4374
- return !!bc && bc !== circularConstraintType;
4373
+ return !!(<Type>target).immediateBaseConstraint;
4375
4374
}
4376
4375
return Debug.fail("Unhandled TypeSystemPropertyName " + propertyName);
4377
4376
}
@@ -6987,30 +6986,26 @@ namespace ts {
6987
6986
* circularly references the type variable.
6988
6987
*/
6989
6988
function getResolvedBaseConstraint(type: InstantiableType | UnionOrIntersectionType): Type {
6990
- let circular: boolean | undefined;
6991
- if (!type.resolvedBaseConstraint) {
6992
- const constraint = getBaseConstraint(type);
6993
- type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type);
6989
+ return type.resolvedBaseConstraint ||
6990
+ (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
6991
+
6992
+ function getImmediateBaseConstraint(t: Type): Type {
6993
+ if (!t.immediateBaseConstraint) {
6994
+ if (!pushTypeResolution(t, TypeSystemPropertyName.ImmediateBaseConstraint)) {
6995
+ return circularConstraintType;
6996
+ }
6997
+ let result = computeBaseConstraint(getSimplifiedType(t));
6998
+ if (!popTypeResolution()) {
6999
+ result = circularConstraintType;
7000
+ }
7001
+ t.immediateBaseConstraint = result || noConstraintType;
7002
+ }
7003
+ return t.immediateBaseConstraint;
6994
7004
}
6995
- return type.resolvedBaseConstraint;
6996
7005
6997
7006
function getBaseConstraint(t: Type): Type | undefined {
6998
- if (t.immediateBaseConstraint) {
6999
- return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint;
7000
- }
7001
- if (!pushTypeResolution(t, TypeSystemPropertyName.ImmediateBaseConstraint)) {
7002
- circular = true;
7003
- t.immediateBaseConstraint = circularConstraintType;
7004
- return undefined;
7005
- }
7006
- const result = computeBaseConstraint(getSimplifiedType(t));
7007
- if (!popTypeResolution()) {
7008
- circular = true;
7009
- t.immediateBaseConstraint = circularConstraintType;
7010
- return undefined;
7011
- }
7012
- t.immediateBaseConstraint = !result ? noConstraintType : result;
7013
- return result;
7007
+ const c = getImmediateBaseConstraint(t);
7008
+ return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
7014
7009
}
7015
7010
7016
7011
function computeBaseConstraint(t: Type): Type | undefined {
0 commit comments