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

Return type of getDotPath function is null for schemas with pipeAsync #814

Closed
declanlscott opened this issue Sep 3, 2024 · 3 comments
Closed
Assignees
Labels
fix A smaller enhancement or bug fix priority This has priority

Comments

@declanlscott
Copy link

declanlscott commented Sep 3, 2024

Thank you for creating this excellent library! This is the first time I've come across any issue after using valibot for some time.

Issue

When using the getDotPath function with an async pipe schema, the resulting return type is null. I have verified this is not the behavior when using a non-async pipe schema.

Minimal reproduction

I also created a minimal reproduction in the playground where you can see hovering over the issuePaths variable reveals null[]. The function returns the correct values, as shown in the logs after running the playground, but the return type is not consistent with this.

Investigation

I did some preliminary investigation and it seems like the condition in the first line of the IssueDotPath type definition fails, eventually resolving the type to never. I'm not sure why this would be happening though?

If this is the expected behavior or if I'm missing something in my implementation, please let me know!

@fabian-hiller
Copy link
Owner

This is a bug. Thank you for creating this PR. It seems to happen whenever pipeAsync contains an async action, but I think I could fix it by changing the following code in the IssueDotPath type:

-TSchema extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe>
-  ? IssueDotPath<FirstTupleItem<TPipe>>
-  : ...
  
+TSchema extends SchemaWithPipe<infer TPipe>
+  ? IssueDotPath<FirstTupleItem<TPipe>>
+  : TSchema extends SchemaWithPipeAsync<infer TPipe>
+    ? IssueDotPath<FirstTupleItem<TPipe>>
+    : ...

Before releasing a new version, I need to investigate if the same happens for other parts of the IssueDotPath type.

@fabian-hiller fabian-hiller self-assigned this Sep 3, 2024
@fabian-hiller fabian-hiller added priority This has priority fix A smaller enhancement or bug fix labels Sep 3, 2024
@fabian-hiller
Copy link
Owner

This will be fixed with the next release

@fabian-hiller
Copy link
Owner

v0.42.0 is available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A smaller enhancement or bug fix priority This has priority
Projects
None yet
Development

No branches or pull requests

2 participants