mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
refactor: fix pipe type
An explicit cast was removed in fa9bce0e9a (diff-29e41c6172a2d68db9886be9e933ed2b477732095313e104c52a725f887276cf)
which relies on [control flow narrowing](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#control-flow-narrowing-for-constant-indexed-accesses) in TS 5.5. However, google3 is still on TS 5.4, so we can't fully depend on that feature. Using an intermediate variable makes the type narrowing work correctly even in TS 5.4.
This commit is contained in:
parent
7c4e0918d9
commit
79821006b8
@ -133,12 +133,13 @@ export function applyPathTemplate<T extends PathTemplateData>(
|
||||
if (!(pipe in data)) {
|
||||
throw new UnknownPipeException(pipe);
|
||||
}
|
||||
if (typeof data[pipe] != 'function') {
|
||||
const pipeFn = data[pipe];
|
||||
if (typeof pipeFn != 'function') {
|
||||
throw new InvalidPipeException(pipe);
|
||||
}
|
||||
|
||||
// Coerce to string.
|
||||
return '' + data[pipe](acc);
|
||||
return '' + pipeFn(acc);
|
||||
}, '' + replacement);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user