Skip to content

Commit

Permalink
core(fr): fix usage of distributed conditional type (#12565)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored May 26, 2021
1 parent 80f4a75 commit a8b22fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lighthouse-core/fraggle-rock/gather/runner-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/** @typedef {Record<CollectPhaseArtifactOptions['phase'], IntermediateArtifacts>} ArtifactState */

/** @typedef {LH.Gatherer.FRTransitionalContext<LH.Gatherer.DependencyKey>['dependencies']} Dependencies */

/**
*
* @param {{id: string}} dependency
Expand Down Expand Up @@ -70,7 +72,7 @@ async function collectPhaseArtifacts(options) {
const artifactPromise = priorArtifactPromise.then(async () => {
const dependencies = phase === 'getArtifact'
? await collectArtifactDependencies(artifactDefn, artifactState.getArtifact)
: {};
: /** @type {Dependencies} */ ({});

return gatherer[phase]({
url: await driver.url(),
Expand All @@ -89,10 +91,10 @@ async function collectPhaseArtifacts(options) {
/**
* @param {LH.Config.ArtifactDefn} artifact
* @param {Record<string, LH.Gatherer.PhaseResult>} artifactsById
* @return {Promise<LH.Gatherer.FRTransitionalContext<LH.Gatherer.DependencyKey>['dependencies']>}
* @return {Promise<Dependencies>}
*/
async function collectArtifactDependencies(artifact, artifactsById) {
if (!artifact.dependencies) return {};
if (!artifact.dependencies) return /** @type {Dependencies} */ ({});

const dependencyPromises = Object.entries(artifact.dependencies).map(
async ([dependencyName, dependency]) => {
Expand Down
4 changes: 1 addition & 3 deletions types/gatherer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ declare global {
/** The cached results of computed artifacts. */
computedCache: Map<string, ArbitraryEqualityMap>;
/** The set of available dependencies requested by the current gatherer. */
dependencies: TDependencies extends DefaultDependenciesKey ?
{} :
Pick<GathererArtifacts, Exclude<TDependencies, DefaultDependenciesKey>>;
dependencies: Pick<GathererArtifacts, Exclude<TDependencies, DefaultDependenciesKey>>;
}

export interface PassContext {
Expand Down

0 comments on commit a8b22fd

Please sign in to comment.