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

Nothing catches non-nullables passed where we expect nullables #47

Open
mjgpy3 opened this issue Oct 14, 2024 · 0 comments
Open

Nothing catches non-nullables passed where we expect nullables #47

mjgpy3 opened this issue Oct 14, 2024 · 0 comments

Comments

@mjgpy3
Copy link
Contributor

mjgpy3 commented Oct 14, 2024

Non-nullable types are accepted and compile/lint just fine in our various maybe-js combinators:

const plusOne = (foo: number): null | undefined | number =>
  mmap(v => v + 1, foo)

Ideally something (tsc/lint) would disallow this (since foo is shown to be a number, i.e. NonNullable<>) in order to stunt the proliferation of unnecessary optional values.

You probably wouldn't write this directly in code most of the time. However, this poses an issue when doing any type of refactoring.

For example, in our codebase we had type Standard = ... & { domain: null | Domain } everywhere in our codebase. This entailed a bunch of uses of maybe-js to handle the optional standard.domain. Over time we made the field required, changing the type definition to type Standard = ... & { domain: Domain }. maybe not checking this left optionals and optional handling downstream of this change.

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

No branches or pull requests

1 participant