Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose: Type withState as any #32326

Merged
merged 5 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ via props.

_Parameters_

- _initialState_ `?Object`: Optional initial state of the component.
- _initialState_ `any`: Optional initial state of the component.

_Returns_

- `WPComponent`: Wrapped component.
- `any`: 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.


<!-- END TOKEN(Autogenerated API docs) -->
Expand Down
8 changes: 4 additions & 4 deletions packages/compose/src/higher-order/with-state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import createHigherOrderComponent from '../../utils/create-higher-order-componen
*
* @deprecated Use `useState` instead.
*
* @param {?Object} initialState Optional initial state of the component.
* @param {any} initialState Optional initial state of the component.
*
* @return {WPComponent} Wrapped component.
* @return {any} 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( initialState = {} ) {
deprecated( 'wp.compose.withState', {
Expand All @@ -26,8 +26,8 @@ export default function withState( initialState = {} ) {

return createHigherOrderComponent( ( OriginalComponent ) => {
return class WrappedComponent extends Component {
constructor() {
super( ...arguments );
constructor( /** @type {any} */ props ) {
super( props );

this.setState = this.setState.bind( this );

Expand Down
1 change: 1 addition & 0 deletions packages/compose/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"src/higher-order/pure/**/*",
"src/higher-order/with-instance-id/**/*",
"src/higher-order/with-global-events/**/*",
"src/higher-order/with-state/**/*",
"src/hooks/use-async-list/**/*",
"src/hooks/use-constrained-tabbing/**/*",
"src/hooks/use-copy-on-click/**/*",
Expand Down