Closed sschneider-ihre-pvs closed 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.
I decided that next version will be major so this MR will be soon merged.
Well, that was my attempt to cover the list part since the typing in the example was only for string and not for string[]
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
Maybe try the guy that hangout in the totally typescript discord :D this is a really tricky one
Can you share Discord link?
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
8.0 version is released and improvement of R.head are there
Thanks for the MR, but since it is changing typings, can you provide test either in the test file or as a comment here?