Chore: Fix TypeScript strict errors with components using connect (#37109)

* Chore: Fix TypeScript strict errors with components using connect

* Chore: More TypeScript fixes

* Chore: Update strict check values

* Still need to export these types...

* Declare connector at the top of the file

* Careful with find and replace...
This commit is contained in:
Ashley Harrison
2021-07-23 10:33:26 +01:00
committed by GitHub
parent 2b51e94537
commit 75ff031789
20 changed files with 238 additions and 263 deletions

View File

@@ -1,6 +1,6 @@
// Libaries
import React, { PureComponent, FC, ReactNode } from 'react';
import { connect, MapDispatchToProps } from 'react-redux';
import { connect, ConnectedProps } from 'react-redux';
// Utils & Services
import { playlistSrv } from 'app/features/playlist/PlaylistSrv';
// Components
@@ -12,13 +12,19 @@ import { locationUtil, textUtil } from '@grafana/data';
import { updateTimeZoneForSession } from 'app/features/profile/state/reducers';
// Types
import { DashboardModel } from '../../state';
import { KioskMode, StoreState } from 'app/types';
import { KioskMode } from 'app/types';
import { ShareModal } from 'app/features/dashboard/components/ShareModal';
import { SaveDashboardModalProxy } from 'app/features/dashboard/components/SaveDashboard/SaveDashboardModalProxy';
import { locationService } from '@grafana/runtime';
import { toggleKioskMode } from 'app/core/navigation/kiosk';
import { getDashboardSrv } from '../../services/DashboardSrv';
const mapDispatchToProps = {
updateTimeZoneForSession,
};
const connector = connect(null, mapDispatchToProps);
export interface OwnProps {
dashboard: DashboardModel;
isFullscreen: boolean;
@@ -29,10 +35,6 @@ export interface OwnProps {
onAddPanel: () => void;
}
interface DispatchProps {
updateTimeZoneForSession: typeof updateTimeZoneForSession;
}
interface DashNavButtonModel {
show: (props: Props) => boolean;
component: FC<Partial<Props>>;
@@ -50,7 +52,7 @@ export function addCustomRightAction(content: DashNavButtonModel) {
customRightActions.push(content);
}
type Props = OwnProps & DispatchProps;
type Props = OwnProps & ConnectedProps<typeof connector>;
class DashNav extends PureComponent<Props> {
constructor(props: Props) {
@@ -263,10 +265,4 @@ class DashNav extends PureComponent<Props> {
}
}
const mapStateToProps = (state: StoreState) => ({});
const mapDispatchToProps: MapDispatchToProps<DispatchProps, OwnProps> = {
updateTimeZoneForSession,
};
export default connect(mapStateToProps, mapDispatchToProps)(DashNav);
export default connector(DashNav);