fix(language-service): Improve signature selection for pipes with args (#33456)

Pipes with arguments like `slice:0` or `slice:0:1` should not produce
diagnostic errors.

PR closes https://github.com/angular/vscode-ng-language-service/issues/345

PR Close #33456
This commit is contained in:
Keen Yee Liau
2019-10-24 10:17:25 -07:00
committed by Andrew Kushnir
parent 5ed6abe3df
commit 1de757993d
4 changed files with 24 additions and 3 deletions

View File

@ -335,4 +335,4 @@ function offsetSpan(span: Span, amount: number): Span {
function spanOf(sourceSpan: ParseSourceSpan): Span {
return {start: sourceSpan.start.offset, end: sourceSpan.end.offset};
}
}

View File

@ -557,7 +557,7 @@ class PipeSymbol implements Symbol {
selectSignature(types: Symbol[]): Signature|undefined {
let signature = selectSignature(this.tsType, this.context, types) !;
if (types.length == 1) {
if (types.length > 0) {
const parameterType = types[0];
if (parameterType instanceof TypeWrapper) {
let resultType: ts.Type|undefined = undefined;
@ -575,7 +575,7 @@ class PipeSymbol implements Symbol {
}
break;
case 'slice':
resultType = getTypeParameterOf(parameterType.tsType, 'Array');
resultType = parameterType.tsType;
break;
}
if (resultType) {