17782: Fixes almost all tests (4 left) mostly by fixing namespace-type imports.
[arvados-workbench2.git] / src / store / dialog / with-dialog.ts
index d53a79d6efe19f5ccde771f05d1590bd77199f0e..78543fc989db5f30a79a6c11b6021adca265a2ac 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { connect } from 'react-redux';
 import { DialogState } from './dialog-reducer';
 import { Dispatch } from 'redux';
@@ -18,18 +18,20 @@ export type WithDialogDispatchProps = {
 };
 
 export type WithDialogProps<T> = WithDialogStateProps<T> & WithDialogDispatchProps;
-
 export const withDialog = (id: string) =>
-    <T, P>(component: React.ComponentType<WithDialogProps<T> & P>) =>
+    // TODO: How to make compiler happy with & P instead of & any?
+    <T, P>(component: React.ComponentType<WithDialogProps<T> & any>) =>
         connect(mapStateToProps(id), mapDispatchToProps(id))(component);
 
+const emptyData = {};
+
 export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialogStateProps<T> => {
     const dialog = state.dialog[id];
-    return dialog ? dialog : { open: false, data: {} };
+    return dialog ? dialog : { open: false, data: emptyData };
 };
 
 export const mapDispatchToProps = (id: string) => (dispatch: Dispatch): WithDialogDispatchProps => ({
     closeDialog: () => {
         dispatch(dialogActions.CLOSE_DIALOG({ id }));
     }
-});
\ No newline at end of file
+});