-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
Description
A few days ago, we ran into an issue with distributed conditional types on FRTransitionalContext. This caused unexpected behavior when defining a gatherer with multiple dependencies.
The issues with FRTransitionalContext have been resolved by #12565 but this popped up again with GathererMeta.
lighthouse/types/gatherer.d.ts
Lines 98 to 101 in 761e47e
| export type GathererMeta<TDependencies extends DependencyKey = DefaultDependenciesKey> = | |
| TDependencies extends DefaultDependenciesKey ? | |
| GathererMetaNoDependencies : | |
| GathererMetaWithDependencies<TDependencies>; |
Multiple dependencies doesn't produce any errors, but the type is too lenient. For example, these are both valid according to our type definition:
/**
* @type {LH.Gatherer.GathererMeta<'DevtoolsLog'|'Trace'>}
*/
this.meta = {
supportedModes: ['timespan', 'navigation'],
dependencies: {DevtoolsLog: DevtoolsLog.symbol, Trace: Trace.symbol},
}/**
* @type {LH.Gatherer.GathererMeta<'DevtoolsLog'|'Trace'>}
*/
this.meta = {
supportedModes: ['timespan', 'navigation'],
dependencies: {DevtoolsLog: DevtoolsLog.symbol},
}Enforcing the expected behavior with square brackets fixes this, but it also opens pandora's box of other type violations. I haven't found a silver bullet to resolve these issues other than to keep the type definition of GathererMeta. Are these type violations valid, or can we stick with the weaker definition for GathererMeta?
patrickhulce