Skip to content

Commit 7982100

Browse files
committed
refactor: fix pipe type
An explicit cast was removed in fa9bce0#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.
1 parent 7c4e091 commit 7982100

File tree

1 file changed

+3
-2
lines changed
  • packages/angular_devkit/schematics/src/rules

1 file changed

+3
-2
lines changed

packages/angular_devkit/schematics/src/rules/template.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ export function applyPathTemplate<T extends PathTemplateData>(
133133
if (!(pipe in data)) {
134134
throw new UnknownPipeException(pipe);
135135
}
136-
if (typeof data[pipe] != 'function') {
136+
const pipeFn = data[pipe];
137+
if (typeof pipeFn != 'function') {
137138
throw new InvalidPipeException(pipe);
138139
}
139140

140141
// Coerce to string.
141-
return '' + data[pipe](acc);
142+
return '' + pipeFn(acc);
142143
}, '' + replacement);
143144
}
144145

0 commit comments

Comments
 (0)