Skip to content

Use found thisParameter #30596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6890,11 +6890,11 @@ namespace ts {
let s = signature;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
let thisParameter = signature.thisParameter;
if (forEach(unionSignatures, sig => sig.thisParameter)) {
let thisParameter = forEach(unionSignatures, sig => sig.thisParameter);
if (thisParameter) {
// TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
const thisType = getUnionType(map(unionSignatures, sig => sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType), UnionReduction.Subtype);
thisParameter = createSymbolWithType(signature.thisParameter!, thisType);
thisParameter = createSymbolWithType(thisParameter, thisType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need test for this. The best way to get that would be to run tsc in debug mode without fix and figure out which type in your code base was resulting in the crash and get those signatures to make the union type.
Note that seems like your want union of signatures in which first signature doesn't have this parameter.

}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
Expand Down