import hoistNonReactStatics from "hoist-non-react-statics"; import * as React from "react"; import PlatformContext, { PlatformContextType } from "./PlatformContext"; import ShortcutManager from "./ShortcutManager"; export type PlatformProps = { manager: ShortcutManager; notification: string | null; notificationTimestamp: number; setNotification: (notificationAndTimestamp: { notification: string; timestamp: number; }) => any; showSidebar: boolean; setShowSidebar: (showSidebar: boolean) => any; showCommandLine: boolean; setShowCommandLine: (showCommandLine: boolean) => any; }; const withPlatform =

(Component: React.ComponentType

) => { type WrappedComponentPropsExceptProvided = Exclude< keyof P, keyof PlatformProps >; type ForwardedProps = Pick; return hoistNonReactStatics( class WithShortcutComponent extends React.Component { render() { return ( {(PlatformContext: PlatformContextType) => { const { manager, notification, setNotification, notificationTimestamp, showSidebar, setShowSidebar, } = PlatformContext; return ( <> ); }} ); } }, Component ); }; export default withPlatform;