Sitelet https://github.com/angular/angular/commit/dfb129dbfaef8026d4df7e6e4f7d1ec9e2b26d6b
Skip to content

Commit dfb129d

Browse files
petebacondarwinatscott
authored andcommitted
refactor(compiler-cli): move map creation to avoid unnecessary work (#38959) (#39272)
If the `symbol` for the given `node` does not exist then there is no point in creating the `map`. PR Close #38959 PR Close #39272
1 parent 1a1407a commit dfb129d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ export class TypeScriptReflectionHost implements ReflectionHost {
105105
if (!ts.isSourceFile(node)) {
106106
throw new Error(`getExportsOfModule() called on non-SourceFile in TS code`);
107107
}
108-
const map = new Map<string, Declaration>();
109108

110109
// Reflect the module to a Symbol, and use getExportsOfModule() to get a list of exported
111110
// Symbols.
112111
const symbol = this.checker.getSymbolAtLocation(node);
113112
if (symbol === undefined) {
114113
return null;
115114
}
115+
116+
const map = new Map<string, Declaration>();
116117
this.checker.getExportsOfModule(symbol).forEach(exportSymbol => {
117118
// Map each exported Symbol to a Declaration and add it to the map.
118119
const decl = this.getDeclarationOfSymbol(exportSymbol, null);

0 commit comments

Comments
 (0)