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

Added Generics to iterate function #713

Merged
merged 1 commit into from
Aug 5, 2017
Merged

Added Generics to iterate function #713

merged 1 commit into from
Aug 5, 2017

Conversation

DaSchTour
Copy link
Contributor

Replacing any with generics to improve typ strength. This way the function that is passes as a parameter will be checked if it returns the expected output and type information from iteratee to callback function are "passed".

Replacing any with generics to improve typ strength. This way the function that is passes as a parameter will be checked if it returns the expected output and type information from iteratee to callback function are "passed".
@thgreasi
Copy link
Member

thgreasi commented Aug 1, 2017

What if multiple types are stored in the store?
Should we have to do something like .iterate<Type1|Type2|Type3, Type1|Type2|Type3>(/*....*/)?
Should we also keep the any interfaces as well and also let the user define the type(s) that they expect with your overloads?

@DaSchTour
Copy link
Contributor Author

Yes that's right. There would be a list of types that could inside the storage.

For TypeScript 2.3 it would be possible to default generics to any. So if nothing is set any is assumed. It is also still possible to explicitly set this to any by using .iterate<any, any>

I think for multiple types stored at least the output will be on type in many cases, so definitions will look like this .iterate<any, Type1> or .iterate<Type1|Type2|Type3, Type4>

But maybe it's also a good idea to keep the old definitions. I'll check if it behaves like I expect.

@thgreasi thgreasi merged commit 64c564b into localForage:master Aug 5, 2017
@thgreasi
Copy link
Member

thgreasi commented Aug 5, 2017

Thanks 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants