selfrefactor / rambda

Faster and smaller alternative to Ramda
https://selfrefactor.github.io/rambda
MIT License
1.65k stars 89 forks source link

Imrove R.head #682

Closed sschneider-ihre-pvs closed 1 year ago

selfrefactor commented 1 year ago

Thanks for the MR, but since it is changing typings, can you provide test either in the test file or as a comment here?

selfrefactor commented 1 year ago

I will have to decline the merge of this MR at this point because of this test:

it('empty array - case 2', () => {
    const list = ['foo', 'bar'].filter(x => x.startsWith('a'))
    const result = head(list)
    result // $ExpectType string | undefined
  })

which is somehow valid case.

Still I will not close it, but keep it open until the next major bump and I will merge it then. Again, thanks for the effort.

selfrefactor commented 1 year ago

I decided that next version will be major so this MR will be soon merged.

sschneider-ihre-pvs commented 1 year ago

Well, that was my attempt to cover the list part since the typing in the example was only for string and not for string[]

selfrefactor commented 1 year ago

I am trying to improve this MR with proper testing but I fail to nail it. I intend to test also these solutions:

https://github.com/millsp/ts-toolbelt/blob/master/sources/List/List.ts https://github.com/sindresorhus/type-fest/blob/main/source/last-array-element.d.ts

sschneider-ihre-pvs commented 1 year ago

Maybe try the guy that hangout in the totally typescript discord :D this is a really tricky one

selfrefactor commented 1 year ago

Can you share Discord link?

selfrefactor commented 1 year ago

I was finally satisfied with https://github.com/sindresorhus/type-fest/blob/main/source/last-array-element.d.ts

I will close the issue, but I will ping you from here once 8.0 is released

sschneider-ihre-pvs commented 1 year ago

https://discord.gg/8S5ujhfTB3

selfrefactor commented 1 year ago

8.0 version is released and improvement of R.head are there