Skip to content

Commit 0ca081e

Browse files
authoredApr 22, 2019
Removed HOC rest props workaround found fixed in recent TSResolved #101 (#163)
1 parent 278ba35 commit 0ca081e

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed
 

‎README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,11 @@ interface InjectedProps {
491491
}
492492

493493
export const withState = <BaseProps extends InjectedProps>(
494-
BaseComponent: React.ComponentType<BaseProps>
494+
_BaseComponent: React.ComponentType<BaseProps>
495495
) => {
496+
// fix for TypeScript issues: https://github.com/piotrwitek/react-redux-typescript-guide/issues/111
497+
const BaseComponent = _BaseComponent as React.ComponentType<InjectedProps>;
498+
496499
type HocProps = Subtract<BaseProps, InjectedProps> & {
497500
// here you can extend hoc with new props
498501
initialCount?: number;
@@ -516,7 +519,7 @@ export const withState = <BaseProps extends InjectedProps>(
516519
};
517520

518521
render() {
519-
const { ...restProps } = this.props as {};
522+
const { ...restProps } = this.props;
520523
const { count } = this.state;
521524

522525
return (
@@ -563,8 +566,11 @@ interface InjectedProps {
563566
}
564567

565568
export const withErrorBoundary = <BaseProps extends InjectedProps>(
566-
BaseComponent: React.ComponentType<BaseProps>
569+
_BaseComponent: React.ComponentType<BaseProps>
567570
) => {
571+
// fix for TypeScript issues: https://github.com/piotrwitek/react-redux-typescript-guide/issues/111
572+
const BaseComponent = _BaseComponent as React.ComponentType<InjectedProps>;
573+
568574
type HocProps = Subtract<BaseProps, InjectedProps> & {
569575
// here you can extend hoc with new props
570576
};
@@ -596,9 +602,7 @@ export const withErrorBoundary = <BaseProps extends InjectedProps>(
596602
};
597603

598604
render() {
599-
const { children, ...restProps } = this.props as {
600-
children: React.ReactNode;
601-
};
605+
const { children, ...restProps } = this.props;
602606
const { error } = this.state;
603607

604608
if (error) {

‎playground/package-lock.json

+22-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎playground/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"dependencies": {
2222
"@babel/polyfill": "7.4.3",
2323
"@types/jest": "24.0.11",
24-
"@types/node": "11.13.4",
25-
"@types/prop-types": "15.7.0",
26-
"@types/react": "16.8.13",
24+
"@types/node": "11.13.6",
25+
"@types/prop-types": "15.7.1",
26+
"@types/react": "16.8.14",
2727
"@types/react-dom": "16.8.4",
28-
"@types/react-redux": "7.0.6",
28+
"@types/react-redux": "7.0.8",
2929
"@types/react-router-dom": "4.3.2",
3030
"@types/react-router-redux": "5.0.18",
3131
"axios": "0.18.0",
@@ -45,8 +45,8 @@
4545
"reselect": "4.0.0",
4646
"rxjs": "6.4.0",
4747
"tslib": "1.9.3",
48-
"tslint": "5.15.0",
49-
"typesafe-actions": "4.1.0",
48+
"tslint": "5.16.0",
49+
"typesafe-actions": "4.1.1",
5050
"typescript": "3.4.4",
5151
"utility-types": "3.5.0"
5252
},

‎playground/src/hoc/with-error-boundary.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ interface InjectedProps {
99
}
1010

1111
export const withErrorBoundary = <BaseProps extends InjectedProps>(
12-
BaseComponent: React.ComponentType<BaseProps>
12+
_BaseComponent: React.ComponentType<BaseProps>
1313
) => {
14+
// fix for TypeScript issues: https://github.com/piotrwitek/react-redux-typescript-guide/issues/111
15+
const BaseComponent = _BaseComponent as React.ComponentType<InjectedProps>;
16+
1417
type HocProps = Subtract<BaseProps, InjectedProps> & {
1518
// here you can extend hoc with new props
1619
};
@@ -42,9 +45,7 @@ export const withErrorBoundary = <BaseProps extends InjectedProps>(
4245
};
4346

4447
render() {
45-
const { children, ...restProps } = this.props as {
46-
children: React.ReactNode;
47-
};
48+
const { children, ...restProps } = this.props;
4849
const { error } = this.state;
4950

5051
if (error) {

‎playground/src/hoc/with-state.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ interface InjectedProps {
88
}
99

1010
export const withState = <BaseProps extends InjectedProps>(
11-
BaseComponent: React.ComponentType<BaseProps>
11+
_BaseComponent: React.ComponentType<BaseProps>
1212
) => {
13+
// fix for TypeScript issues: https://github.com/piotrwitek/react-redux-typescript-guide/issues/111
14+
const BaseComponent = _BaseComponent as React.ComponentType<InjectedProps>;
15+
1316
type HocProps = Subtract<BaseProps, InjectedProps> & {
1417
// here you can extend hoc with new props
1518
initialCount?: number;
@@ -33,7 +36,7 @@ export const withState = <BaseProps extends InjectedProps>(
3336
};
3437

3538
render() {
36-
const { ...restProps } = this.props as {};
39+
const { ...restProps } = this.props;
3740
const { count } = this.state;
3841

3942
return (

0 commit comments

Comments
 (0)
Failed to load comments.