Skip to content

Commit

Permalink
Fix hoc typing
Browse files Browse the repository at this point in the history
  • Loading branch information
li-kai committed Feb 11, 2019
1 parent 5be1ef7 commit 8dad8a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions www/src/js/views/hocs/makeResponsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface WithBreakpoint {
matchBreakpoint: boolean;
}

function makeResponsive<Props>(
function makeResponsive<Props extends WithBreakpoint>(
WrappedComponent: React.ComponentType<Props>,
mediaQuery: string | QueryObject | QueryObject[],
): React.ComponentType<Omit<Props, keyof WithBreakpoint>> {
Expand Down Expand Up @@ -43,8 +43,11 @@ function makeResponsive<Props>(
};

render() {
// @ts-ignore TODO: Figure out what's wrong here
return <WrappedComponent matchBreakpoint={this.state.matchBreakpoint} {...this.props} />;
return (
// TODO: remove as Props hack as defined in:
// https://github.com/Microsoft/TypeScript/issues/28938#issuecomment-450636046
<WrappedComponent {...this.props as Props} matchBreakpoint={this.state.matchBreakpoint} />
);
}
};
}
Expand Down
5 changes: 3 additions & 2 deletions www/src/js/views/hocs/withTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ function withTimer<Props extends TimerData>(
};

render() {
// @ts-ignore TODO: Figure out what's wrong here
return <WrappedComponent {...this.state} {...this.props} />;
// TODO: remove as Props hack as defined in:
// https://github.com/Microsoft/TypeScript/issues/28938#issuecomment-450636046
return <WrappedComponent {...this.state} {...this.props as Props} />;
}
};
}
Expand Down

0 comments on commit 8dad8a3

Please sign in to comment.