Skip to content

Commit

Permalink
refactor(cache): simplify condition w/ optional chaining (#356)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
agilgur5 authored Jun 14, 2022
1 parent 4f93c44 commit a31cda1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tscache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit a31cda1

Please sign in to comment.