From 9048ebd4964acbd6bc2404550940258e3939de45 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 26 Mar 2024 11:02:37 +0100 Subject: [PATCH] refactor: Replace filter + map with for-loop --- src/detectors/typeChecker/host.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/detectors/typeChecker/host.ts b/src/detectors/typeChecker/host.ts index 5ea216a98..1a1cfaca5 100644 --- a/src/detectors/typeChecker/host.ts +++ b/src/detectors/typeChecker/host.ts @@ -33,10 +33,14 @@ async function collectTransitiveDependencies(pkgName: string, deps: Set) async function collectSapui5TypesFiles() { const typesDir = path.dirname(require.resolve("@sapui5/types/package.json")); - const typesFiles = await fs.readdir(path.join(typesDir, "types"), {withFileTypes: true}); - return typesFiles - .filter((entry) => entry.isFile() && entry.name.endsWith(".d.ts") && entry.name !== "index.d.ts") - .map((entry) => entry.name); + const allFiles = await fs.readdir(path.join(typesDir, "types"), {withFileTypes: true}); + const typesFiles = []; + for (const entry of allFiles) { + if (entry.isFile() && entry.name.endsWith(".d.ts") && entry.name !== "index.d.ts") { + typesFiles.push(entry.name); + } + } + return typesFiles; } function addSapui5TypesMappingToCompilerOptions(sapui5TypesFiles: string[], options: ts.CompilerOptions) {