Cell success prop types are still potentially null

Hi all,

I’ve decided to throw caution to the wind and go full on strict TS mode, in the hope that if I can make it through the pain it’ll be easier on the other side!

My latest issue is how to type the returned object from a success cell. I’ve tried using the query type, e.g.:


but this includes the null/undefined possibilities as well:

    __typename?: "Category" | undefined;
    id: number;
    name: string;
    parentCategoryId?: number | null | undefined;
    childCategories?: {
    }[] | null | undefined;
} | null | undefined

Just wondering if there was any way to say that there is definitely going to be an object returned, as it’s in the success component (rather than error or empty)?

I’d also be interested to know if there are any RW-specific resources for getting up and running with TS strict - maybe an example project? I use TS in my other projects but there’s a decent amount of additional complexity here with the Apollo and RW layers. I’ve had a hunt around here/Discord but haven’t seen many conversations about it. The docs have this page - https://redwoodjs.com/docs/typescript/strict-mode.- which is useful but doesn’t cover all of my issues!


1 Like

I think I’ve sorted this specific issue using the CellSuccessProps generic. I had tried that before but had got the syntax a bit wrong.

This is what seems to be working for me:


On to the next problem!

Glad you found a solution. I’d have to dig to find where, but I’ve ended up needing TS utility types (like Required) a few times in working with the generated types in Redwood.

1 Like