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 should be inferred from calls labels and functions return type #4

Open
enzoferey opened this issue Aug 12, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@enzoferey
Copy link
Owner

As of right now the returned type needs to be typed manually like:

createWatcher<Value>
getBatchedValuesOnce<Value>
useBatchedValues<Value>
useBatchedValuesOnce<Value>

This is error prone because the passed calls can change (the label or returned type does not match anymore), so the library should be able to infer the Value type from the calls labels and functions return type.

Inferring the labels should be straightforward with some TypeScript magic. Inferring the labels' types also requires some TypeScript magic but should be doable.

An alternative solution could be to wrap the calls generators in some glue that defines its types, so everything about a call would be defined where the call is defined and then the function using it would pick up those definitions.

@enzoferey enzoferey added the enhancement New feature or request label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant