__Expected behavior:__
Typescript 3.0 added support for defaultProps in React.
Using WithStyles seems to break this behavior.
__Describe the bug:__
Props are reported as required even though they are defaulted using a public static defaultProps field.
__Codesandbox link:__
The following code should do it but I can't make it work in CodeSandbox. For some reason, it keeps marking React as any which can't trigger the error.
Here is the url anyway: https://codesandbox.io/s/fk93m
import * as React from "react";
import { render } from "react-dom";
import injectSheet, { WithStyles } from "react-jss";
const styles = {
blue: {
color: "blue"
}
};
interface IProps extends WithStyles<typeof styles> {
count: number;
}
class App extends React.Component<IProps> {
public static defaultProps = {
//count: 18 // Enabling this line triggers a type error when Using RealApp below
};
public render() {
const { classes, count } = this.props;
return <div className={classes.blue}>The count is {count}.</div>;
}
}
const RealApp = injectSheet(styles)(App);
render(<RealApp />, document.getElementById("root"));
__Versions (please complete the following information):__
I will have a look today. Thanks for reporting
Thank you! Let me know if I can help!
Hi, any news on this?
Most helpful comment
I will have a look today. Thanks for reporting