mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Don’t crash when creating a union signature from signatures that do and don’t have this types
This commit is contained in:
@@ -7052,10 +7052,10 @@ namespace ts {
|
||||
// Union the result types when more than one signature matches
|
||||
if (unionSignatures.length > 1) {
|
||||
let thisParameter = signature.thisParameter;
|
||||
if (forEach(unionSignatures, sig => sig.thisParameter)) {
|
||||
// TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
|
||||
const firstThisParameterOfUnionSignatures = forEach(unionSignatures, sig => sig.thisParameter);
|
||||
if (firstThisParameterOfUnionSignatures) {
|
||||
const thisType = getUnionType(map(unionSignatures, sig => sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType), UnionReduction.Subtype);
|
||||
thisParameter = createSymbolWithType(signature.thisParameter!, thisType);
|
||||
thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
|
||||
}
|
||||
s = createUnionSignature(signature, unionSignatures);
|
||||
s.thisParameter = thisParameter;
|
||||
|
||||
Reference in New Issue
Block a user