fix(language-service): Improve signature selection by finding exact match (#37494)

The function signature selection algorithm is totally naive. It'd
unconditionally pick the first signature if there are multiple
overloads. This commit improves the algorithm by returning an exact
match if one exists.

PR Close #37494
This commit is contained in:
Keen Yee Liau
2020-03-27 15:32:51 +01:00
committed by atscott
parent 8d817daf78
commit 6280cf95b4
4 changed files with 53 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import * as ParsingCases from './parsing-cases';
ParsingCases.StringModel,
ParsingCases.TemplateReference,
ParsingCases.TestComponent,
ParsingCases.TestPipe,
ParsingCases.WithContextDirective,
]
})

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, EventEmitter, Input, OnChanges, Output, SimpleChanges, TemplateRef, ViewContainerRef} from '@angular/core';
import {Component, Directive, EventEmitter, Input, OnChanges, Output, Pipe, PipeTransform, SimpleChanges, TemplateRef, ViewContainerRef} from '@angular/core';
import {Hero} from './app.component';
@ -69,6 +69,20 @@ export class WithContextDirective {
}
}
@Pipe({
name: 'prefixPipe',
})
export class TestPipe implements PipeTransform {
transform(value: string, prefix: string): string;
transform(value: number, prefix: number): number;
transform(value: string|number, prefix: string|number): string|number {
if (typeof value === 'string') {
return `${prefix} ${value}`;
}
return parseInt(`${prefix}${value}`, 10 /* radix */);
}
}
/**
* This Component provides the `test-comp` selector.
*/