mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 12:57:11 -06:00
Remove duplicate call/construct signatures in intersections
This commit is contained in:
parent
3ca2e7dbb8
commit
762fff1f65
@ -7234,8 +7234,8 @@ namespace ts {
|
||||
function resolveIntersectionTypeMembers(type: IntersectionType) {
|
||||
// The members and properties collections are empty for intersection types. To get all properties of an
|
||||
// intersection type use getPropertiesOfType (only the language service uses this).
|
||||
let callSignatures: ReadonlyArray<Signature> = emptyArray;
|
||||
let constructSignatures: ReadonlyArray<Signature> = emptyArray;
|
||||
let callSignatures: Signature[] | undefined;
|
||||
let constructSignatures: Signature[] | undefined;
|
||||
let stringIndexInfo: IndexInfo | undefined;
|
||||
let numberIndexInfo: IndexInfo | undefined;
|
||||
const types = type.types;
|
||||
@ -7257,13 +7257,22 @@ namespace ts {
|
||||
return clone;
|
||||
});
|
||||
}
|
||||
constructSignatures = concatenate(constructSignatures, signatures);
|
||||
constructSignatures = appendSignatures(constructSignatures, signatures);
|
||||
}
|
||||
callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call));
|
||||
callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, SignatureKind.Call));
|
||||
stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, IndexKind.String));
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, IndexKind.Number));
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || emptyArray, constructSignatures || emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
|
||||
function appendSignatures(signatures: Signature[] | undefined, newSignatures: readonly Signature[]) {
|
||||
for (const sig of newSignatures) {
|
||||
if (!signatures || every(signatures, s => !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical))) {
|
||||
signatures = append(signatures, sig);
|
||||
}
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user