Error adding Component state when using graphql wrapper as decorator
Steps to Reproduce
Adding a state type to a React Component class when decorated with the graphql wrapper function.
@graphql<IData, IProps>(query)
class TodoApp extends React.Component<IProps, IState> {
public render() {
const { todos } = this.props;
return (
<ul>
{todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul>
);
}
}
Buggy Behavior
The newly added type checking breaks my code with a error TS1238: Unable to resolve signature of class decorator when called as an expression. when adding state type, but only if the graphql wrapper function is used as a decorator. With 'normal' wrapping (see below) everything is fine.
const withData = graphql<IData, IProps>(query);
class TodoApp extends React.Component<IProps, IState> {
public render() {
const { todos } = this.props;
return (
<ul>
{todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul>
);
}
}
const container = withData(TodoApp);
And of course in the initial decorated code, replacing IState with any works (which might be the reason why the tests are succeeding).
ADDITION:
I'm also unable to add functions to a react class as it starts complaining: Property 'foo' is missing in type 'Component<IProps, ComponentState>'. Again only when decorating the classes. Am I using this correctly?
Version
same issue here
Is there any update on this? I'm now stuck with using version 1.2.0..
seeing this as well
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo!
I'm seeing this issue on react-apollo 1.4.8. I'm unable to add any methods or variables to the component class or using a typed state (any-type works as reported above). When doing so I get the error message "Unable to resolve signature of class decorator when called as an expression. ...".
Have anyone got this to work?
So unless I do something wrong the decorator is at the moment unusable. I vote to reopen this issue.
"react": "^15.6.1", "react-apollo": "^1.4.8", "react-dom": "^15.6.1",
It's possible to patch original graphql decorator (oversee from mobx-react) but there is need to define additional property (innerProps) for typesafe: https://gist.github.com/mctep/adda5750271f8b0d181e0328e68afb56
@samvik same here, using @mctep seems to fix the msg
same here. decorations make code looks very cleaner. please fix this.