mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Allow base constructor types to be intersections
This commit is contained in:
parent
a9af10b030
commit
c16c7d56c0
@ -3810,7 +3810,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isConstructorType(type: Type): boolean {
|
||||
return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Construct).length > 0;
|
||||
return isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0;
|
||||
}
|
||||
|
||||
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments {
|
||||
@ -3849,7 +3849,7 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
const baseConstructorType = checkExpression(baseTypeNode.expression);
|
||||
if (baseConstructorType.flags & TypeFlags.Object) {
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) {
|
||||
// Resolving the members of a class requires us to resolve the base class of that class.
|
||||
// We force resolution here such that we catch circularities now.
|
||||
resolveStructuredTypeMembers(<ObjectType>baseConstructorType);
|
||||
@ -3890,7 +3890,7 @@ namespace ts {
|
||||
function resolveBaseTypesOfClass(type: InterfaceType): void {
|
||||
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
|
||||
const baseConstructorType = <ObjectType>getBaseConstructorTypeOfClass(type);
|
||||
if (!(baseConstructorType.flags & TypeFlags.Object)) {
|
||||
if (!(baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection))) {
|
||||
return;
|
||||
}
|
||||
const baseTypeNode = getBaseTypeNodeOfClass(type);
|
||||
@ -4591,9 +4591,9 @@ namespace ts {
|
||||
constructSignatures = getDefaultConstructSignatures(classType);
|
||||
}
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
if (baseConstructorType.flags & TypeFlags.Object) {
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) {
|
||||
members = createSymbolTable(getNamedMembers(members));
|
||||
addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType));
|
||||
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
||||
}
|
||||
}
|
||||
const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user