Skip to content

Commit

Permalink
withFallbackStyles: Convert to TypeScript (#48720)
Browse files Browse the repository at this point in the history
* withFallbackStyles: Convert to TypeScript

* Update changelog
  • Loading branch information
mirka committed Mar 3, 2023
1 parent 45e038e commit 0016e83
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `Guide`: Convert to TypeScript ([#47493](https://github.com/WordPress/gutenberg/pull/47493)).
- `PanelBody`: Convert to TypeScript ([#47702](https://github.com/WordPress/gutenberg/pull/47702)).
- `withFallbackStyles` HOC: Convert to TypeScript ([#48720](https://github.com/WordPress/gutenberg/pull/48720)).
- `navigateRegions` HOC: Convert to TypeScript ([#48632](https://github.com/WordPress/gutenberg/pull/48632)).

## 23.5.0 (2023-03-01)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ import fastDeepEqual from 'fast-deep-equal/es6';
import { Component } from '@wordpress/element';
import { createHigherOrderComponent } from '@wordpress/compose';

export default ( mapNodeToProps ) =>
type Props = {
node?: HTMLElement;
[ key: string ]: any;
};

type State = {
fallbackStyles?: { [ key: string ]: any };
grabStylesCompleted: boolean;
};

export default (
mapNodeToProps: (
node: HTMLElement,
props: Props
) => { [ key: string ]: any }
) =>
createHigherOrderComponent( ( WrappedComponent ) => {
return class extends Component {
constructor() {
super( ...arguments );
return class extends Component< Props, State > {
nodeRef?: HTMLElement;

constructor( props: Props ) {
super( props );
this.nodeRef = this.props.node;
this.state = {
fallbackStyles: undefined,
Expand All @@ -23,7 +40,7 @@ export default ( mapNodeToProps ) =>
this.bindRef = this.bindRef.bind( this );
}

bindRef( node ) {
bindRef( node: HTMLDivElement ) {
if ( ! node ) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"src/dimension-control",
"src/duotone-picker",
"src/gradient-picker",
"src/higher-order/with-fallback-styles",
"src/higher-order/with-filters",
"src/higher-order/with-focus-return",
"src/higher-order/with-notices",
Expand Down

1 comment on commit 0016e83

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 0016e83.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4323032447
📝 Reported issues:

Please sign in to comment.