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

applySchema does not accept plain functions #163

Closed
danielweinmann opened this issue Jul 15, 2024 · 3 comments
Closed

applySchema does not accept plain functions #163

danielweinmann opened this issue Jul 15, 2024 · 3 comments

Comments

@danielweinmann
Copy link
Contributor

I get the following error when trying to use applySchema with a plain function:

  const increment = (value: number) => value + 1
  const incrementWithSchema = applySchema(z.number())(increment)

// Argument of type '(value: number) => number' is not assignable to parameter of type '((input: number, context: unknown) => Promise<Result<unknown>>) & { kind: "composable"; }'.
//   Type '(value: number) => number' is not assignable to type '(input: number, context: unknown) => Promise<Result<unknown>>'.
//     Type 'number' is not assignable to type 'Promise<Result<unknown>>'.ts(2345)

If I wrap it with composable, everything works fine.

  const increment = composable((value: number) => value + 1)
  const incrementWithSchema = applySchema(z.number())(increment)
@gustavoguichard
Copy link
Collaborator

gustavoguichard commented Jul 15, 2024

Yup, this is planned. And, once we do that, applySchema and withSchema will do the same thing. Use withSchema for plain functions in the meantime

@gustavoguichard
Copy link
Collaborator

@danielweinmann #164 should solve this issue =)

@gustavoguichard
Copy link
Collaborator

Solved on v4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants