@@ -3608,37 +3608,29 @@ namespace ts {
3608
3608
3609
3609
function resolveAnonymousTypeMembers(type: AnonymousType) {
3610
3610
const symbol = type.symbol;
3611
- let members: SymbolTable;
3612
- let callSignatures: Signature[];
3613
- let constructSignatures: Signature[];
3614
- let stringIndexType: Type;
3615
- let numberIndexType: Type;
3616
-
3617
3611
if (type.target) {
3618
- members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
3619
- callSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper, instantiateSignature);
3620
- constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature);
3621
- stringIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.String), type.mapper);
3622
- numberIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.Number), type.mapper);
3612
+ const members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
3613
+ const callSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper, instantiateSignature);
3614
+ const constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature);
3615
+ const stringIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.String), type.mapper);
3616
+ const numberIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.Number), type.mapper);
3617
+ setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
3623
3618
}
3624
3619
else if (symbol.flags & SymbolFlags.TypeLiteral) {
3625
- members = symbol.members;
3626
- callSignatures = getSignaturesOfSymbol(members["__call"]);
3627
- constructSignatures = getSignaturesOfSymbol(members["__new"]);
3628
- stringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String);
3629
- numberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number);
3620
+ const members = symbol.members;
3621
+ const callSignatures = getSignaturesOfSymbol(members["__call"]);
3622
+ const constructSignatures = getSignaturesOfSymbol(members["__new"]);
3623
+ const stringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String);
3624
+ const numberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number);
3625
+ setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
3630
3626
}
3631
3627
else {
3632
3628
// Combinations of function, class, enum and module
3633
- members = emptySymbols;
3634
- callSignatures = emptyArray;
3635
- constructSignatures = emptyArray;
3629
+ let members = emptySymbols;
3630
+ let constructSignatures: Signature[] = emptyArray;
3636
3631
if (symbol.flags & SymbolFlags.HasExports) {
3637
3632
members = getExportsOfSymbol(symbol);
3638
3633
}
3639
- if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
3640
- callSignatures = getSignaturesOfSymbol(symbol);
3641
- }
3642
3634
if (symbol.flags & SymbolFlags.Class) {
3643
3635
const classType = getDeclaredTypeOfClassOrInterface(symbol);
3644
3636
constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
@@ -3651,10 +3643,16 @@ namespace ts {
3651
3643
addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType));
3652
3644
}
3653
3645
}
3654
- stringIndexType = undefined;
3655
- numberIndexType = (symbol.flags & SymbolFlags.Enum) ? stringType : undefined;
3646
+ const numberIndexType = (symbol.flags & SymbolFlags.Enum) ? stringType : undefined;
3647
+ setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexType);
3648
+ // We resolve the members before computing the signatures because a signature may use
3649
+ // typeof with a qualified name expression that circularly references the type we are
3650
+ // in the process of resolving (see issue #6072). The temporarily empty signature list
3651
+ // will never be observed because a qualified name can't reference signatures.
3652
+ if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
3653
+ (<ResolvedType>type).callSignatures = getSignaturesOfSymbol(symbol);
3654
+ }
3656
3655
}
3657
- setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
3658
3656
}
3659
3657
3660
3658
function resolveStructuredTypeMembers(type: ObjectType): ResolvedType {
0 commit comments