Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Typescript typings: #810

Closed
tomitrescak opened this issue Jun 30, 2017 · 5 comments · Fixed by #862
Closed

Typescript typings: #810

tomitrescak opened this issue Jun 30, 2017 · 5 comments · Fixed by #862
Assignees
Labels

Comments

@tomitrescak
Copy link

tomitrescak commented Jun 30, 2017

Expected Behavior

I should be able to use React.Components with graphql wrapper.
Example:

const historyQuery = gql`
  query history($solutionId: String) {
    history(solutionId: $solutionId) {
      solutionId
      delta
    }
  }`;

type Data = {
  history: App.Entities.History[]
};

type Props = {
  solutionId: string;
};

const withHistory = graphql<Data, Props>(historyQuery,
  {
    options: (ownProps) => ({
      variables: {
        solutionId: ownProps.solutionId
      }
    })
  });

export class HistoryView extends React.Component<{}, {}> {
}

export default withHistory(HistoryView);

Leads to following error:

Argument of type 'typeof HistoryView' is not assignable to parameter of type 'CompositeComponent<DefaultChildProps<Props, Data>>'.
  Type 'typeof HistoryView' is not assignable to type 'StatelessComponent<DefaultChildProps<Props, Data>>'.
    Type 'typeof HistoryView' provides no match for the signature '(props: Props & { data?: QueryProps & Data; mutate?: MutationFunc<Data>; } & { children?: ReactNode; }, context?: any): ReactElement<any>'.

Looks like you only accept stateless components, although opposite seems to be the truth.
Not sure what is going on.

Version

@morriq
Copy link

morriq commented Jul 2, 2017

same here! It's happend with 1.4.0

@dfischer
Copy link

Same issue for me with 1.4.3 had to downgrade to 1.4.0

@hxuanhung
Copy link

@dfischer which version of TS that you are on?

@hxuanhung
Copy link

I had to downgraded to [email protected] and [email protected]

@jbaxleyiii
Copy link
Contributor

I'm working on a fix that will allow this to work in 1.4.4 🌮

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants