React-apollo: Type error in 2.1.11 in graphql.d.ts 'ComponentClass<P>' requires between 0 and 1 type arguments

Created on 10 Aug 2018  路  2Comments  路  Source: apollographql/react-apollo

Run tsc --noEmit in a project that uses react-apollo with skipLibCheck to false using typescript 3.0.1

node_modules/react-apollo/graphql.d.ts:4:395 - error TS2707: Generic type 'ComponentClass<P>' requires between 0 and 1 type arguments.

4 export declare function graphql<TProps extends TGraphQLVariables | {} = {}, TData = {}, TGraphQLVariables = {}, TChildProps = Partial<DataProps<TData, TGraphQLVariables>> & Partial<MutateProps<TData, TGraphQLVariables>>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TChildProps & TProps>) => React.ComponentClass<TProps, React.ComponentState>;

Versions
Node 8.11.3
Npm 6.30
react-apollo 2.1.11

Most helpful comment

@zamiang I recently ran into this as well. Looks like the types for react-apollo are correct.

There was a recent change in the @types/react package (see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/27417/files) that added a second generic to the React.ComponentClass type definition.

I fixed this issue by upgrading my @types/react to the most recent version (16.4.9).

Notes:

  • I also upgraded react-dom to 16.0.7
  • I also upgraded prop-types to 15.5.5
  • I also used yarn and had to remove yarn.lock to handle nested dependencies. This issue (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20350#issuecomment-352409487) explains this situation pretty well.

All 2 comments

@zamiang I recently ran into this as well. Looks like the types for react-apollo are correct.

There was a recent change in the @types/react package (see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/27417/files) that added a second generic to the React.ComponentClass type definition.

I fixed this issue by upgrading my @types/react to the most recent version (16.4.9).

Notes:

  • I also upgraded react-dom to 16.0.7
  • I also upgraded prop-types to 15.5.5
  • I also used yarn and had to remove yarn.lock to handle nested dependencies. This issue (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20350#issuecomment-352409487) explains this situation pretty well.

Please update your dependencies and you should be good to go. I just merged a PR which reenabled lib checking and it was all green.

Was this page helpful?
0 / 5 - 0 ratings