Make exportMetrics strict
Summary: _typescript_ Reviewed By: danielbuechele Differential Revision: D17074932 fbshipit-source-id: 1a6a8e81a9d15021dd9b51a0c3a394a2cf349e9c
This commit is contained in:
committed by
Facebook Github Bot
parent
5c69ad8e8b
commit
9a63ee9fff
@@ -26,17 +26,21 @@ async function exportMetrics(
|
||||
const pluginStateData = pluginStates[key];
|
||||
const arr = key.split('#');
|
||||
const pluginName = arr.pop();
|
||||
if (selectedPlugins.length > 0 && !selectedPlugins.includes(pluginName)) {
|
||||
if (
|
||||
pluginName === undefined ||
|
||||
(selectedPlugins.length > 0 && !selectedPlugins.includes(pluginName))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const clientID = arr.join('#');
|
||||
const plugin = pluginsMap.get(pluginName);
|
||||
const metricsReducer: (
|
||||
persistedState: any,
|
||||
) => Promise<MetricType> | undefined = plugin && plugin.metricsReducer;
|
||||
const metricsReducer:
|
||||
| (<U>(persistedState: U) => Promise<MetricType>)
|
||||
| null
|
||||
| undefined = plugin && plugin.metricsReducer;
|
||||
if (pluginsMap.has(pluginName) && metricsReducer) {
|
||||
const metricsObject = await metricsReducer(pluginStateData);
|
||||
const pluginObject = {};
|
||||
const pluginObject: MetricPluginType = {};
|
||||
pluginObject[pluginName] = metricsObject;
|
||||
if (!metrics[clientID]) {
|
||||
metrics[clientID] = pluginObject;
|
||||
|
||||
Reference in New Issue
Block a user