From 62a99b70b8aa69c45c0a120e7885e8d5d550f1bc Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:46:28 -0400 Subject: [PATCH] refactor(@angular-devkit/schematics): avoid for await...of with promise arrays The upcoming version of typescript Eslint rules will fail the `await-thenable` rule for cases of for await...of that use promise arrays. This change removes the usage to avoid lint failures during the version update. Ref: https://typescript-eslint.io/rules/await-thenable/#async-iteration-for-awaitof-loops --- packages/angular_devkit/schematics/src/rules/base.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/angular_devkit/schematics/src/rules/base.ts b/packages/angular_devkit/schematics/src/rules/base.ts index 5b14e927db..ab91954b83 100644 --- a/packages/angular_devkit/schematics/src/rules/base.ts +++ b/packages/angular_devkit/schematics/src/rules/base.ts @@ -35,8 +35,14 @@ export function empty(): Source { export function chain(rules: Iterable | AsyncIterable): Rule { return async (initialTree, context) => { let intermediateTree: Observable | undefined; - for await (const rule of rules) { - intermediateTree = callRule(rule, intermediateTree ?? initialTree, context); + if (Symbol.asyncIterator in rules) { + for await (const rule of rules) { + intermediateTree = callRule(rule, intermediateTree ?? initialTree, context); + } + } else { + for (const rule of rules) { + intermediateTree = callRule(rule, intermediateTree ?? initialTree, context); + } } return () => intermediateTree;