wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.

Home Page:https://wasp-lang.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve type signature for `void` RPCs

sodic opened this issue · comments

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).