This cannot be prevented. What is an unclean pipe for?
What can you do to make sure that there is as little work inside the method as possible transform(), for example, by caching the results and only recount when the passed value has really changed.
Object.keys() .
. [ ] * ngFor Angular 2
ChangeDetectionStrategy.OnPush , .