Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type signature for void RPCs #2004

Open
sodic opened this issue May 3, 2024 · 0 comments
Open

Improve type signature for void RPCs #2004

sodic opened this issue May 3, 2024 · 0 comments
Labels
bug Something isn't working dx

Comments

@sodic
Copy link
Contributor

sodic commented May 3, 2024

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

@sodic sodic added bug Something isn't working dx labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dx
Projects
None yet
Development

No branches or pull requests

1 participant