fix(eslint): remove type assertions in ShareExport.tsx
- Change openSaveAsDialog to accept unknown type instead of specific types - Use runtime type checking to extract title property safely - This avoids the need for type assertions which violate consistent-type-assertions rule
This commit is contained in:
@@ -60,13 +60,16 @@ export const ShareExport = memo(({ dashboard, panel, onDismiss }: Props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const openSaveAsDialog = (dash: Record<string, unknown> & { title?: string }) => {
|
||||
const openSaveAsDialog = (dash: unknown) => {
|
||||
const dashboardJsonPretty = JSON.stringify(dash, null, 2);
|
||||
const blob = new Blob([dashboardJsonPretty], {
|
||||
type: 'application/json;charset=utf-8',
|
||||
});
|
||||
const time = new Date().getTime();
|
||||
const title = dash.title && typeof dash.title === 'string' ? dash.title : 'dashboard';
|
||||
const title =
|
||||
typeof dash === 'object' && dash !== null && 'title' in dash && typeof dash.title === 'string'
|
||||
? dash.title
|
||||
: 'dashboard';
|
||||
saveAs(blob, `${title}-${time}.json`);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user