From 8c0664d864a00c8d6a3bf6d04d26cc2255600435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Sedl=C3=A1k?= Date: Fri, 17 Dec 2021 09:24:51 +0100 Subject: [PATCH] Dependency walker map checking supports new TS ModeAwareCache https://github.com/microsoft/TypeScript/blob/1cee9731d22c7a1f97ac957cb89d8664cadc4717/src/compiler/moduleNameResolver.ts#L660 fixes #499 --- .../karma-typescript/src/bundler/dependency-walker.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/karma-typescript/src/bundler/dependency-walker.ts b/packages/karma-typescript/src/bundler/dependency-walker.ts index fe714947..9b020785 100644 --- a/packages/karma-typescript/src/bundler/dependency-walker.ts +++ b/packages/karma-typescript/src/bundler/dependency-walker.ts @@ -30,6 +30,15 @@ export class DependencyWalker { let dependencyCount = 0; const ambientModuleNames = this.collectAmbientModules(queue); + // check resolved modules map for TS >= 4.5.1 + const isTS45Map = function (map: any) { + return typeof map.get === "function" && + typeof map.set === "function" && + typeof map.delete === "function" && + typeof map.has === "function" && + typeof map.forEach === "function" && + typeof map.size === "function"; + } queue.forEach((queued) => { @@ -39,7 +48,7 @@ export class DependencyWalker { if (resolvedModules && !queued.emitOutput.isDeclarationFile) { - if (lodash.isMap(resolvedModules)) { // Typescript 2.2+ + if (isTS45Map(resolvedModules) || lodash.isMap(resolvedModules)) { // Typescript 2.2+ resolvedModules.forEach((resolvedModule: any, moduleName: string) => { this.addBundleItem(queued, resolvedModule, moduleName, ambientModuleNames); });