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

feat: 🎸 prevent mapping with void functions (WIP?) #78

Open
wants to merge 1 commit into
base: tap
Choose a base branch
from

Conversation

Retsam
Copy link
Collaborator

@Retsam Retsam commented Nov 12, 2019

This is a potential implementation of the changes described in #76. Disallowing void functions from being passed to .map turned out to be more tricky than I initially thought.

This works, but with a major caveat: it also blocks functions that return undefined. I couldn't find a way to permit unknown without permitting void, (as void is assignable to unknown). They'd have to cast their unknowns as NotVoid.


So I'm not completely happy with this change; I'm putting it up as something between a WiP and a PoC.

To avoid issues with accidentally mapping to none, prevent .map from being called with void functions.

BREAKING CHANGE: .map no longer accepts void functions (or ones that return unknown), use tap instead.
@Retsam Retsam requested a review from andnp as a code owner November 12, 2019 18:50
@codecov
Copy link

codecov bot commented Nov 12, 2019

Codecov Report

Merging #78 into tap will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##            tap    #78   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files         6      6           
  Lines       117    117           
  Branches     11     11           
===================================
  Hits        117    117
Impacted Files Coverage Δ
src/maybe.ts 100% <100%> (ø) ⬆️
src/some.ts 100% <100%> (ø) ⬆️
src/transformer.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16518c5...9802f36. Read the comment docs.

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.

1 participant