Hey! I’m using the following pattern to add some type safety to my API responses:
type ApiReturn =
| {}
| {}
| {};
// ...
return Response.json({
// ...
} satisfies ApiReturn);
Is it possible to override the type of Response.json so it only accepts values matching the ApiReturn type? I played around with this idea a bit but couldn't get it to work.
This might not be specific to Bun's types, but I saw that they do some trickery with Bun.__internal.UseLibDomIfAvailable so I presume it would require a unique solution.