@@ -1400,10 +1400,10 @@ namespace ts {
1400
1400
return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
1401
1401
}
1402
1402
1403
- function getTargetOfExportSpecifier(node: ExportSpecifier, dontResolveAlias?: boolean): Symbol {
1404
- return (<ExportDeclaration> node.parent.parent) .moduleSpecifier ?
1405
- getExternalModuleMember(<ExportDeclaration> node.parent.parent, node, dontResolveAlias) :
1406
- resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace , /*ignoreErrors*/ false, dontResolveAlias);
1403
+ function getTargetOfExportSpecifier(node: ExportSpecifier, meaning: SymbolFlags, dontResolveAlias?: boolean) {
1404
+ return node.parent.parent.moduleSpecifier ?
1405
+ getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
1406
+ resolveEntityName(node.propertyName || node.name, meaning , /*ignoreErrors*/ false, dontResolveAlias);
1407
1407
}
1408
1408
1409
1409
function getTargetOfExportAssignment(node: ExportAssignment, dontResolveAlias: boolean): Symbol {
@@ -1421,7 +1421,7 @@ namespace ts {
1421
1421
case SyntaxKind.ImportSpecifier:
1422
1422
return getTargetOfImportSpecifier(<ImportSpecifier>node, dontRecursivelyResolve);
1423
1423
case SyntaxKind.ExportSpecifier:
1424
- return getTargetOfExportSpecifier(<ExportSpecifier>node, dontRecursivelyResolve);
1424
+ return getTargetOfExportSpecifier(<ExportSpecifier>node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, dontRecursivelyResolve);
1425
1425
case SyntaxKind.ExportAssignment:
1426
1426
return getTargetOfExportAssignment(<ExportAssignment>node, dontRecursivelyResolve);
1427
1427
case SyntaxKind.NamespaceExportDeclaration:
@@ -3721,10 +3721,7 @@ namespace ts {
3721
3721
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node);
3722
3722
}
3723
3723
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
3724
- const exportSpecifier = <ExportSpecifier>node.parent;
3725
- exportSymbol = (<ExportDeclaration>exportSpecifier.parent.parent).moduleSpecifier ?
3726
- getExternalModuleMember(<ExportDeclaration>exportSpecifier.parent.parent, exportSpecifier) :
3727
- resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
3724
+ exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
3728
3725
}
3729
3726
const result: Node[] = [];
3730
3727
if (exportSymbol) {
@@ -9228,25 +9225,39 @@ namespace ts {
9228
9225
let result = Ternary.True;
9229
9226
const saveErrorInfo = errorInfo;
9230
9227
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;
9228
+ if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) {
9229
+ // We instantiations of the same anonymous type (which typically will be the type of a method).
9230
+ // Simply do a pairwise comparison of the signatures in the two signature lists instead of the
9231
+ // much more expensive N * M comparison matrix we explore below.
9232
+ for (let i = 0; i < targetSignatures.length; i++) {
9233
+ const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors);
9234
+ if (!related) {
9235
+ return Ternary.False;
9240
9236
}
9241
- shouldElaborateErrors = false ;
9237
+ result &= related ;
9242
9238
}
9239
+ }
9240
+ else {
9241
+ outer: for (const t of targetSignatures) {
9242
+ // Only elaborate errors from the first failure
9243
+ let shouldElaborateErrors = reportErrors;
9244
+ for (const s of sourceSignatures) {
9245
+ const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9246
+ if (related) {
9247
+ result &= related;
9248
+ errorInfo = saveErrorInfo;
9249
+ continue outer;
9250
+ }
9251
+ shouldElaborateErrors = false;
9252
+ }
9243
9253
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));
9254
+ if (shouldElaborateErrors) {
9255
+ reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9256
+ typeToString(source),
9257
+ signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9258
+ }
9259
+ return Ternary.False;
9248
9260
}
9249
- return Ternary.False;
9250
9261
}
9251
9262
return result;
9252
9263
}
0 commit comments