The source of the autogenerated type below stems from a GraphQL query:
export type OfferQuery = { __typename?: 'Query' } & {
offer: Types.Maybe<
{ __typename?: 'Offer' } & Pick<Types.Offer, 'id' | 'name'> & {
payouts: Array<
{ __typename?: 'Payout' } & Pick<
Types.Payout,
'weGet' | 'theyGet'
> & {
offer: { __typename?: 'Offer' } & Pick<Types.Offer, 'id'>;
publisher: Types.Maybe<
{ __typename?: 'Publisher' } & Pick<Types.Publisher, 'id'>
>;
eventType: Types.Maybe<
{ __typename?: 'EventType' } & Pick<
Types.EventType,
'id' | 'name'
>
>;
}
>;
}
>;
};
I am interested in utilizing parts of the OfferQuery type within my react component, specifically a payout element.
type Payout = OfferQuery['offer']['payouts'][number];
Unfortunately, I encounter an error
"Property 'payouts' does not exist on type 'Maybe{ __typename?: "Offer" | undefined; }..."
.
Could you suggest a workaround to tackle this issue and still access the payouts definition?
tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-jsx",
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext"
}
}
Typescript 4.1.3