From f9fb1210e979c1a76a2a9a7014093041303905dd Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 22 Mar 2019 10:55:31 -0700 Subject: [PATCH] prevOptions should be optional --- packages/grafana-ui/src/types/panel.ts | 2 +- public/app/plugins/panel/singlestat2/module.tsx | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/grafana-ui/src/types/panel.ts b/packages/grafana-ui/src/types/panel.ts index 1878c858167..bd535655551 100644 --- a/packages/grafana-ui/src/types/panel.ts +++ b/packages/grafana-ui/src/types/panel.ts @@ -32,7 +32,7 @@ export type PanelMigrationHook = (options: Partial) => export type PanelTypeChangedHook = ( options: Partial, prevPluginId: string, - prevOptions: any + prevOptions?: any ) => Partial; export class ReactPanelPlugin { diff --git a/public/app/plugins/panel/singlestat2/module.tsx b/public/app/plugins/panel/singlestat2/module.tsx index 6ce0de69dbc..4b2c27c360a 100644 --- a/public/app/plugins/panel/singlestat2/module.tsx +++ b/public/app/plugins/panel/singlestat2/module.tsx @@ -11,13 +11,15 @@ const optionsToKeep = ['valueOptions', 'stat', 'maxValue', 'maxValue', 'threshol export const singleStatBaseOptionsCheck = ( options: Partial, prevPluginId: string, - prevOptions: any + prevOptions?: any ) => { - optionsToKeep.forEach(v => { - if (prevOptions.hasOwnProperty(v)) { - options[v] = cloneDeep(prevOptions.display); - } - }); + if (prevOptions) { + optionsToKeep.forEach(v => { + if (prevOptions.hasOwnProperty(v)) { + options[v] = cloneDeep(prevOptions.display); + } + }); + } return options; };