selfrefactor / rambdax

Extended version of Rambda
https://selfrefactor.github.io/rambdax
MIT License
221 stars 26 forks source link

Update type definition of `last` #100

Closed deiga closed 5 months ago

deiga commented 6 months ago

last would return undefined if input is an array of length 0, but this is not reflected in the type definition

selfrefactor commented 5 months ago

Txs for spotting this. I did merge it to master, but I need to add more changes before making a release. I will update once release is made.

selfrefactor commented 3 months ago

I added the comment about 0 length, but the change that will be in next version is a bit different. Still, the end result is the same:

it('empty array', () => {
    const list = [] as const
    head(emptyList) // $ExpectType undefined
    head(list) // $ExpectType undefined
    last(emptyList) // $ExpectType undefined
    last(list) // $ExpectType undefined
  })

I will inform when it is released.

selfrefactor commented 2 months ago

It is released with latest version