You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Intended outcome:
I expect the following code, in which I pass a React Functional Component that I wrote into MockedProvider, to work without type error:
Actual outcome:
But I get this error on my use of MockedProvider:
Type '{ children: (string | Element)[]; mocks: never[]; addTypename: false; }' is not assignable to type 'Partial<Pick<Readonly<MockedProviderProps<{}>> & Readonly<{ children?: ReactNode; }>, "link" | "mocks" | "addTypename" | "defaultOptions" | "cache" | "resolvers" | "childProps" | "children">>'.
Types of property 'children' are incompatible.
Type '(string | Element)[]' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> | ... 7 more ... | undefined'.
Type '(string | Element)[]' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> & ReactNodeArray'.
Type '(string | Element)[]' is missing the following properties from type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>': type, props, keyts(2322)
Note: modifying the return type of MyModal did not fix the issue, nor did passing multiple <MyModal /> elements into <MockedProvider />.
How to reproduce the issue:
Let me know if I need to put together a sample repo with the above two files.
I fixed the type error by manually editing my node_modules/@apollo/react-testing/lib/mocks/types.d.ts file, changing the children property of MockedProviderProps:
Intended outcome:
I expect the following code, in which I pass a React Functional Component that I wrote into
MockedProvider
, to work without type error:Actual outcome:
But I get this error on my use of
MockedProvider
:Note: modifying the return type of
MyModal
did not fix the issue, nor did passing multiple<MyModal />
elements into<MockedProvider />
.How to reproduce the issue:
Let me know if I need to put together a sample repo with the above two files.
I fixed the type error by manually editing my
node_modules/@apollo/react-testing/lib/mocks/types.d.ts
file, changing thechildren
property ofMockedProviderProps
:A workaround in my code was to wrap my functional component in a React Fragment:
Versions
Also my
yarn.lock
shows that@types/react
is at version16.9.25
, if that's relevant.My
tsconfig.json
contains:The text was updated successfully, but these errors were encountered: