Skip to content

Conversation

@Harris-Miller
Copy link
Collaborator

Simplify typings on assoc

Turns out that overloading for the specific key/value scenarios is harder on typescript than returning a complex type checking via ternaries. This works better for pretty much all scenarios. Especially when passing results from curried assoc calls into other functions, eg pipe(assoc('key', 'value')) or [].map(assoc('key', 'value'))

See example here: https://tsplay.dev/Na5r0N

Fixes: #35
And: #37 (comment)

@Harris-Miller Harris-Miller force-pushed the assoc-non-breaking-updates branch from 7c425ad to 7352edb Compare March 2, 2024 04:35
@Harris-Miller Harris-Miller merged commit 6027164 into develop Mar 2, 2024
@Harris-Miller Harris-Miller deleted the assoc-non-breaking-updates branch March 2, 2024 04:38
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.

assoc returns a narrower type than what is passed

2 participants