-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix(types): narrow return type of first
and last
#160
fix(types): narrow return type of first
and last
#160
Conversation
first
and last
Benchmark Results
Generally speaking, any regression ≥20% should be investigated if it wasn't to be expected. |
first
and last
first
and last
Hi @aleclarson, I have filled out |
@crishoj Sorry, I renamed this PR so it's a |
Oh, no worries 😃 |
Co-authored-by: Marlon Passos <1marlonpassos@gmail.com>
Co-authored-by: Marlon Passos <1marlonpassos@gmail.com>
edf0da4
to
e4a4e17
Compare
My changes have enabled const val1 = first([1, 2])
// ^? 1
const val2 = last([1, 2])
// ^? 2 |
Neat! Inferred type for |
Summary
As with
draw()
in #153, we can narrow the return type forfirst()
andlast()
in case the argument is known to be empty or non-empty.With custom
defaultValue
:Related issue, if any:
draw
signature for non-empty arrays #153first
andlast
#140For any code change,
Does this PR introduce a breaking change?
No
Calculating...