Hi folks, having had a bit of a background in TypeScript - I switched on "strict": true for my redwood app a long time ago and for quite a while accepted that while the types for my app were pretty accurate, they were not always right and often hard to work with:
Error messages were very verbose
It was hard to describe types where the SDL types and Prisma models did not align perfectly
You could not really use those types to pass data between resolvers which wasn’t represented in the SDL
My recommendation is to add a new "scripts" for "types": "redwood-alt-api-codegen --eslint-fix " - then you can write yarn types and it will do the work. If you’d like to have the in-app types handle for you, I also made an ESLint rule to add the correct types to your resolvers ( here Custom ESLint Rules in Redwood )
Shipped 1.1.0 of the type generator, it now inlines the type narrowing for a resolver function’s return type making it trivial to re-use those in tests or through other files, with a focus on async funcs in particular:
In concrete terms, for something like summaryAsync or gameAsync which are the majority of my resolvers (and nearly always the ones I want to test) the type has gone from string | Promise<string> | (() => Promise<string>); to Promise<string> - which means your tests dont need an as to tell TS you know the types.
In theory, I could do the same for a non async function, but it’d need to use the types from TypeScript, and I’m not gonna slow down the generator for that as I want it on an instant watch-mode eventually.