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 · May be fixed by #2044
Open

Improve type signature for void RPCs #2004

sodic opened this issue May 3, 2024 · 0 comments · May be fixed by #2044
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
@sodic sodic linked a pull request Jun 12, 2024 that will close this issue
5 tasks
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

Successfully merging a pull request may close this issue.

1 participant