prevOptions should be optional

This commit is contained in:
ryan 2019-03-22 10:55:31 -07:00
parent d8595e9f4e
commit f9fb1210e9
2 changed files with 9 additions and 7 deletions

View File

@ -32,7 +32,7 @@ export type PanelMigrationHook<TOptions = any> = (options: Partial<TOptions>) =>
export type PanelTypeChangedHook<TOptions = any> = (
options: Partial<TOptions>,
prevPluginId: string,
prevOptions: any
prevOptions?: any
) => Partial<TOptions>;
export class ReactPanelPlugin<TOptions = any> {

View File

@ -11,13 +11,15 @@ const optionsToKeep = ['valueOptions', 'stat', 'maxValue', 'maxValue', 'threshol
export const singleStatBaseOptionsCheck = (
options: Partial<SingleStatBaseOptions>,
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;
};