From a31cda15a9b7c74a0782f7715a55adefe9cec743 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Tue, 14 Jun 2022 10:36:04 -0400 Subject: [PATCH] refactor(cache): simplify condition w/ optional chaining (#356) - as I've done in other places, simplify a condition by using optional chaining syntax (over the previously necessary syntax with `&&` etc) - also add a new line to the first `.map` here - for style consistency and because this is a super long line - this wasn't possible before the lodash refactor because it was all one big single statement in the chain --- src/tscache.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tscache.ts b/src/tscache.ts index 8b3a962..e3582b7 100644 --- a/src/tscache.ts +++ b/src/tscache.ts @@ -132,8 +132,9 @@ export class TsCache this.dependencyTree = new Graph({ directed: true }); this.dependencyTree.setDefaultNodeLabel((_node: string) => ({ dirty: false })); - const automaticTypes = tsModule.getAutomaticTypeDirectiveNames(options, tsModule.sys).map((entry) => tsModule.resolveTypeReferenceDirective(entry, undefined, options, tsModule.sys)) - .filter((entry) => entry.resolvedTypeReferenceDirective && entry.resolvedTypeReferenceDirective.resolvedFileName) + const automaticTypes = tsModule.getAutomaticTypeDirectiveNames(options, tsModule.sys) + .map((entry) => tsModule.resolveTypeReferenceDirective(entry, undefined, options, tsModule.sys)) + .filter((entry) => entry.resolvedTypeReferenceDirective?.resolvedFileName) .map((entry) => entry.resolvedTypeReferenceDirective!.resolvedFileName!); this.ambientTypes = rootFilenames.filter(file => file.endsWith(".d.ts"))