diff --git a/packages/compose/src/higher-order/with-state/index.tsx b/packages/compose/src/higher-order/with-state/index.tsx index eacd8ee1c3f0eb..60c04126aca9f0 100644 --- a/packages/compose/src/higher-order/with-state/index.tsx +++ b/packages/compose/src/higher-order/with-state/index.tsx @@ -1,9 +1,3 @@ -/** - * External dependencies - */ -// eslint-disable-next-line no-restricted-imports -import type { ComponentType } from 'react'; - /** * WordPress dependencies */ @@ -14,8 +8,6 @@ import deprecated from '@wordpress/deprecated'; * Internal dependencies */ import createHigherOrderComponent from '../../utils/create-higher-order-component'; -// eslint-disable-next-line no-duplicate-imports -import type { HigherOrderComponent } from '../../utils/create-higher-order-component'; /** * A Higher Order Component used to provide and manage internal component state @@ -27,37 +19,18 @@ import type { HigherOrderComponent } from '../../utils/create-higher-order-compo * * @return A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props. */ -export default function withState< - TProps extends object, - TStateProps extends object ->( - initialState: TStateProps = {} as TStateProps -): HigherOrderComponent< - TProps & - TStateProps & { - setState: Component< TProps, TStateProps >[ 'setState' ]; - }, - TProps -> { +export default function withState( + initialState: any +): any { deprecated( 'wp.compose.withState', { alternative: 'wp.element.useState', } ); + return createHigherOrderComponent( ( - OriginalComponent: ComponentType< - TProps & - TStateProps & { - setState: Component< - TProps, - TStateProps - >[ 'setState' ]; - } - > + OriginalComponent: any ) => { - return class WrappedComponent extends Component< - TProps, - TStateProps - > { + return class WrappedComponent extends Component { constructor( props: any ) { super( props ); @@ -69,8 +42,8 @@ export default function withState< render() { return ( );