rest.ts icon indicating copy to clipboard operation
rest.ts copied to clipboard

undefined converted to void in POST body types

Open asktree opened this issue 5 years ago • 2 comments
trafficstars

Let's say my POST query has an optional parameter:

const myBody = {arg: "" as string | undefined}

The driver will instead expect a body of type

{arg: string | void}

This is pretty annoying. I can't tell if it's an unknown bug, or some weird TypeScript thing that you don't have a good workaround for.

asktree avatar Jul 16 '20 09:07 asktree

This looks like a bug.

Can you provide a practical example where having void instead of undefined causes problems?

hmil avatar Jul 16 '20 20:07 hmil

Sometimes I want a field to be undefined in the body or response of a REST query. For example, if a certain endpoint is passed an auth token, it should associate the activity with a specific user instead of with an anonymous user. This bug makes that impossible, because undefined !== void.

asktree avatar Jul 21 '20 00:07 asktree