Skip to content

Commit 981956a

Browse files
committed
Merge branch 'master' into moreFactoryFuncs
2 parents d37426d + 1db4f96 commit 981956a

15 files changed

+488
-143
lines changed

src/compiler/checker.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7257,7 +7257,7 @@ namespace ts {
72577257
accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ?
72587258
getPropertyNameForKnownSymbolName((<Identifier>(<PropertyAccessExpression>accessExpression.argumentExpression).name).text) :
72597259
undefined;
7260-
if (propName) {
7260+
if (propName !== undefined) {
72617261
const prop = getPropertyOfType(objectType, propName);
72627262
if (prop) {
72637263
if (accessExpression) {
@@ -9228,25 +9228,39 @@ namespace ts {
92289228
let result = Ternary.True;
92299229
const saveErrorInfo = errorInfo;
92309230

9231-
outer: for (const t of targetSignatures) {
9232-
// Only elaborate errors from the first failure
9233-
let shouldElaborateErrors = reportErrors;
9234-
for (const s of sourceSignatures) {
9235-
const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9236-
if (related) {
9237-
result &= related;
9238-
errorInfo = saveErrorInfo;
9239-
continue outer;
9231+
if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) {
9232+
// We instantiations of the same anonymous type (which typically will be the type of a method).
9233+
// Simply do a pairwise comparison of the signatures in the two signature lists instead of the
9234+
// much more expensive N * M comparison matrix we explore below.
9235+
for (let i = 0; i < targetSignatures.length; i++) {
9236+
const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors);
9237+
if (!related) {
9238+
return Ternary.False;
92409239
}
9241-
shouldElaborateErrors = false;
9240+
result &= related;
92429241
}
9242+
}
9243+
else {
9244+
outer: for (const t of targetSignatures) {
9245+
// Only elaborate errors from the first failure
9246+
let shouldElaborateErrors = reportErrors;
9247+
for (const s of sourceSignatures) {
9248+
const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9249+
if (related) {
9250+
result &= related;
9251+
errorInfo = saveErrorInfo;
9252+
continue outer;
9253+
}
9254+
shouldElaborateErrors = false;
9255+
}
92439256

9244-
if (shouldElaborateErrors) {
9245-
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9246-
typeToString(source),
9247-
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9257+
if (shouldElaborateErrors) {
9258+
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9259+
typeToString(source),
9260+
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9261+
}
9262+
return Ternary.False;
92489263
}
9249-
return Ternary.False;
92509264
}
92519265
return result;
92529266
}

src/compiler/core.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ namespace ts {
251251
}
252252
}
253253

254+
export function zipToMap<T>(keys: string[], values: T[]): Map<T> {
255+
Debug.assert(keys.length === values.length);
256+
const map = createMap<T>();
257+
for (let i = 0; i < keys.length; ++i) {
258+
map.set(keys[i], values[i]);
259+
}
260+
return map;
261+
}
262+
254263
/**
255264
* Iterates through `array` by index and performs the callback on each element of array until the callback
256265
* returns a falsey value, then returns false.

src/compiler/diagnosticMessages.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,9 +3203,16 @@
32033203
},
32043204
"Scoped package detected, looking in '{0}'": {
32053205
"category": "Message",
3206-
"code": "6182"
3206+
"code": 6182
3207+
},
3208+
"Reusing resolution of module '{0}' to file '{1}' from old program.": {
3209+
"category": "Message",
3210+
"code": 6183
3211+
},
3212+
"Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program.": {
3213+
"category": "Message",
3214+
"code": 6184
32073215
},
3208-
32093216
"Variable '{0}' implicitly has an '{1}' type.": {
32103217
"category": "Error",
32113218
"code": 7005

0 commit comments

Comments
 (0)