-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Generic types for get, set, select, and apply; immutability for apply callback input #512
Comments
Could also add a ReadOnlyCursor generic type. Then a caller can cast a cursor before giving it to callee, and ensure callee does not set any data. |
From afar it looks nice but I must admit I am not skilled enough in TS to know whether it would mess up with other people's code. @jacomyal any insights? |
Very likely to cause typescript build errors in any codebases that have some unknown (likely irrelevant) type errors in their baobab tree. Users may want to fix those type errors but would be a pain in the ass if you're not active on a project and just wanted to update dependencies. Two options:
|
Oh also some packages (e.g. lodash.get) explicitly type out 7 or so levels deep the return types for everything. I think it's slightly faster than this All that said I still think I could take the time to do this PR proper if yall decide you'd use it |
Oh you or I could also publish as a separate npm package. |
@qpwo I think it would be a good first step to test the water indeed. I guess you would release something like the code presented above? |
Yeah I'll give it a try |
Okay giving it a shot today |
Some reason didn't get linked. This is PR #513 |
It's nice to catch typos in keys in selectors, know the type of selected data, etc. I'll paste in my code so far here because it's not ready for a PR or anything yet. Figured I'd ask before trying to make it tidy and work well in a proper PR, do you want this functionality in the repo?
Catching typos:
Return types on get:
Immutability for apply callback:
Full code follows. still has some bugs. Will improve if there's interest.
The text was updated successfully, but these errors were encountered: