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

Dataloader infers wrong type from load method when returning non-base errors #951

Open
hayes opened this issue Jul 6, 2023 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@hayes
Copy link
Owner

hayes commented Jul 6, 2023

The typing for the load method is not ideal, it basically is typed as load: (some args) => MaybePromse<Error | Shape> where Shape a generic without any constraints. This means if load returns Promise<User | Error> Shape is inferred as being User. The better way to handle this would be to have load be defined as something like load: (some args) => MaybePromse<LoadResult> and then other places that use Shape would be updated to do something like ShapeFromLoadResult<LoadResult> instead of Shape. ShapeFromLoadResult would probably be something like type ShapeFromLoadResult<T> = T extends Error ? never : T

@hayes hayes added good first issue Good for newcomers bug Something isn't working labels Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant