Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(fr): more precise AnyFRInterface types #12622

Merged
merged 3 commits into from
Jun 7, 2021

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Jun 4, 2021

Summary
Fixes the issue raised in #12619

The type violations were in fact valid and stemmed from my abuse of Interface<AllPossibleKeys> to be a substitute for Interface<Key1> | Interface<Key2> | Interface<Key3>. I introduced AnyInterface types to more accurately reflect when a function accepts or returns any possible artifact/gatherer/dependency object instead. This still has the limitation that it doesn't programmatically generate the combinatorial versions, but I haven't bumped into a scenario where the handling differs/matters yet.

Solves @adamraine 's original point (see screenshot)

image

Related Issues/PRs
fixes #12619
ref #11313

@patrickhulce patrickhulce requested a review from adamraine June 4, 2021 19:43
@patrickhulce patrickhulce requested a review from a team as a code owner June 4, 2021 19:43
@google-cla google-cla bot added the cla: yes label Jun 4, 2021
@@ -108,7 +108,9 @@ function resolveArtifactsToDefns(artifacts, configDir) {
throw new Error(`${gatherer.instance.name} gatherer does not support Fraggle Rock`);
}

/** @type {LH.Config.ArtifactDefn<LH.Gatherer.DependencyKey>} */
/** @type {LH.Config.AnyArtifactDefn} */
// @ts-expect-error - Typescript can't validate the gatherer and dependencies match
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only place I couldn't figure out how to solve.

🤓 🔫 @brendankenny if you're interested :)

the only thing I could think was to re-validate that resolveArtifactDependencies matches outside the function, but that seemed excessive

lighthouse-core/test/fraggle-rock/gather/mock-driver.js Outdated Show resolved Hide resolved
types/gatherer.d.ts Show resolved Hide resolved
types/config.d.ts Show resolved Hide resolved
Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@patrickhulce patrickhulce merged commit f462016 into master Jun 7, 2021
@patrickhulce patrickhulce deleted the fr_fix_gatherer_meta_type branch June 7, 2021 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TS issues in FR Gatherer Meta
3 participants