Parameterizes the bindReporter type on the metric passed in so that the callback can now be typed specifically for that metric (e.g. a result for CLSMetric must be using a CLSReportCallback).
This required initMetric to be parameterized similarly, so the returned metric type is now based on the metric name passed in.
let metric = initMetric('FCP');
// ^ FCPMetric
The main change required was using a union of the metric types wherever the base Metric interface is currently used. This leaves most uses of it unchanged, but allows narrowing to which specific metric is being used based on the name property.
I renamed the existing Metric to be MetricBase and named the union Metric to keep the uses of it unchanged, but if someone has better naming suggestions, changing is no problem :)
Can land after #356
Parameterizes the
bindReporter
type on themetric
passed in so that thecallback
can now be typed specifically for that metric (e.g. a result forCLSMetric
must be using aCLSReportCallback
).This required
initMetric
to be parameterized similarly, so the returned metric type is now based on the metricname
passed in.The main change required was using a union of the metric types wherever the base
Metric
interface is currently used. This leaves most uses of it unchanged, but allows narrowing to which specific metric is being used based on thename
property.I renamed the existing
Metric
to beMetricBase
and named the unionMetric
to keep the uses of it unchanged, but if someone has better naming suggestions, changing is no problem :)