wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.49k stars 1.18k forks source link

Improve type signature for `void` RPCs #2004

Closed sodic closed 3 months ago

sodic commented 5 months ago

For any void backend Operation, such as:

export const getAnything: GetAnything = async () => {
  return 'anything'
}

The inferred payload type is args: void. Calling Parameters<typeof getAnything> returns [args?: void | undefined]:

// What we have
type Params = Parameters<typeof getAnything> // Params = [args?: void | undefined]
getAnything()          // works
getAnything(undefined) // works

// What we want
type Params = Parameters<typeof getAnything> // Params = []
getAnything()          // works
getAnything(undefined) // doesn't work

It works well enough for most use cases, but is not 100% correct (i.e., it will allow a call without arguments, but will also allow a call with undefined).