I'm trying to use the Material UI 1.0 (beta) @withStyles annotation on a React component. The docs give a Javascript example (https://material-ui-1dab0.firebaseapp.com/customization/css-in-js), but it gives a compile error in Typescript. It actually emits ok and the app runs fine, so am just trying to rid the IDE of the error!
Here is my code:
@withStyles(styles)
class MyComponent extends React.Component<any, any> {
manager: any;
...
}
This gives error:
TS1238: Unable to resolve signature of class decorator when called as an expression.
Type 'ComponentClass<StyledComponentProps<{}>>' is not assignable to type 'typeof MyComponent'.
Type 'Component<StyledComponentProps<{}>, ComponentState>' is not assignable to type 'MyComponent'.
Property 'manager' is missing in type 'Component<StyledComponentProps<{}>, ComponentState>'.
I don't really understand this error. I can use the alternative non-annotated version like this:
const MyStyledComponent = withStyles(styles)(MyComponent);
and this compiles/runs without issues. I'd prefer to use annotations though, and I'd like to understand the error.
Any advice appreciated!