-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimestate: has PR
Milestone
Description
Description
As you can see on the reference below, the case "truncate" only for strings.
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({name: 'truncate'})
export class TruncatePipe implements PipeTransform {
transform(value: any) {
return value.split(' ').slice(0, 2).join(' ') + '...';
}
}
(in this example, return value.split(' ')slice(0, 2).join(' ') + '…' in .split is a string-only built-in object method.)
The parameter type value of the 'transform' method is any, but at least in the example truncate, the parameter of 'transform' must be string.
Therefore, it seems that it should be changed to 'transform(value: string)' or that there should be a logic inside to check if the type value is string.
Minimal Reproduction
What's the affected URL?**
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimestate: has PR