docs(core): tighten up PipeTransform example types (#42240)

The example was using `any` type but then assuming that the value was a string.

Fixes #42239

PR Close #42240
This commit is contained in:
Pete Bacon Darwin 2021-05-22 12:50:10 +01:00 committed by Zach Arend
parent 4ac55ca676
commit bf505ad707
2 changed files with 4 additions and 4 deletions

View File

@ -5,12 +5,12 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// #docregion
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({name: 'truncate'})
export class TruncatePipe implements PipeTransform {
transform(value: any) {
transform(value: string) {
return value.split(' ').slice(0, 2).join(' ') + '...';
}
}

View File

@ -5,12 +5,12 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// #docregion
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({name: 'truncate'})
export class TruncatePipe implements PipeTransform {
transform(value: any, length: number, symbol: string) {
transform(value: string, length: number, symbol: string) {
return value.split(' ').slice(0, length).join(' ') + symbol;
}
}