From ed81588c792c9c1c023bbd537b18b5a4d152e55d Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 29 Sep 2020 20:44:43 +0100 Subject: [PATCH] refactor(compiler-cli): move map creation to avoid unnecessary work (#38959) If the `symbol` for the given `node` does not exist then there is no point in creating the `map`. PR Close #38959 --- packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts b/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts index 85be99477c..202a4c43b3 100644 --- a/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts +++ b/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts @@ -105,7 +105,6 @@ export class TypeScriptReflectionHost implements ReflectionHost { if (!ts.isSourceFile(node)) { throw new Error(`getExportsOfModule() called on non-SourceFile in TS code`); } - const map = new Map(); // Reflect the module to a Symbol, and use getExportsOfModule() to get a list of exported // Symbols. @@ -113,6 +112,8 @@ export class TypeScriptReflectionHost implements ReflectionHost { if (symbol === undefined) { return null; } + + const map = new Map(); this.checker.getExportsOfModule(symbol).forEach(exportSymbol => { // Map each exported Symbol to a Declaration and add it to the map. const decl = this.getDeclarationOfSymbol(exportSymbol, null);