From bf505ad7071f54f44b4bfc18155e55599002e668 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Sat, 22 May 2021 12:50:10 +0100 Subject: [PATCH] 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 --- packages/examples/core/ts/pipes/simple_truncate.ts | 4 ++-- packages/examples/core/ts/pipes/truncate.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/examples/core/ts/pipes/simple_truncate.ts b/packages/examples/core/ts/pipes/simple_truncate.ts index cf13f99663..4f30cd447f 100644 --- a/packages/examples/core/ts/pipes/simple_truncate.ts +++ b/packages/examples/core/ts/pipes/simple_truncate.ts @@ -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(' ') + '...'; } } diff --git a/packages/examples/core/ts/pipes/truncate.ts b/packages/examples/core/ts/pipes/truncate.ts index c37eaa96b6..8e6ac5217f 100644 --- a/packages/examples/core/ts/pipes/truncate.ts +++ b/packages/examples/core/ts/pipes/truncate.ts @@ -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; } }