Skip to content

Commit c0b3835

Browse files
committed
Instantiate signatures if there is an overload resolution error but type arguments present
1 parent 48588b6 commit c0b3835

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8522,6 +8522,9 @@ namespace ts {
85228522
if (!produceDiagnostics) {
85238523
for (let candidate of candidates) {
85248524
if (hasCorrectArity(node, args, candidate)) {
8525+
if (candidate.typeParameters && typeArguments) {
8526+
candidate = getSignatureInstantiation(candidate, map(typeArguments, getTypeFromTypeNode));
8527+
}
85258528
return candidate;
85268529
}
85278530
}

tests/cases/fourslash/genericCombinators2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ goTo.marker('15');
110110
verify.quickInfoIs('var r4a: Collection<number, any>');
111111

112112
goTo.marker('17');
113-
verify.quickInfoIs('var r5a: Collection<T, V>'); // This is actually due to an error because toFixed does not return a Date
113+
verify.quickInfoIs('var r5a: Collection<number, Date>');
114114

115115
goTo.marker('18');
116116
verify.quickInfoIs('var r5b: Collection<number, Date>');
@@ -122,10 +122,10 @@ goTo.marker('20');
122122
verify.quickInfoIs('var r6b: Collection<Collection<number, number>, Date>');
123123

124124
goTo.marker('21');
125-
verify.quickInfoIs('var r7a: Collection<T, V>'); // This call is an error because y.foo() does not return a string
125+
verify.quickInfoIs('var r7a: Collection<number, string>');
126126

127127
goTo.marker('22');
128-
verify.quickInfoIs('var r7b: Collection<T, V>'); // This call is an error because y.foo() does not return a string
128+
verify.quickInfoIs('var r7b: Collection<number, string>');
129129

130130
goTo.marker('23');
131131
verify.quickInfoIs('var r8a: Collection<number, string>');

0 commit comments

Comments
 (0)