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

Typing issue when using isDeepEqual in differenceWith function #641

Closed
eemelipa opened this issue Apr 15, 2024 · 2 comments · Fixed by #642 · May be fixed by tenantcloud/template-sync#6
Closed

Typing issue when using isDeepEqual in differenceWith function #641

eemelipa opened this issue Apr 15, 2024 · 2 comments · Fixed by #642 · May be fixed by tenantcloud/template-sync#6
Assignees
Labels
bug Something isn't working released typing Something type related

Comments

@eemelipa
Copy link

Current Behavior

Doing the following results in typing issue for the firstArray object Argument of type 'string[]' is not assignable to parameter of type 'readonly never[]'. Type 'string' is not assignable to type 'never'.ts(2345)

import * as R from 'remeda'

const firstArray = ['a', 'b', 'c']
const secondArray = ['a', 'c', 'd']

const difference = R.differenceWith(firstArray, secondArray, R.isDeepEqual)

Expected Behavior

It should be possible to directly use the isDeepEqual in the above use case and the types should be ok.

Workaround

At least two workarounds exist:

  1. Explicitly give types for the differentWith
    • R.differenceWith<string, string>(firstArray, secondArray, R.isDeepEqual)
  2. Use some other comparator for the is equal
    • R.differenceWith(firstArray, secondArray, (a, b) => a === b)

Related Information

This used to work in version 1.58.0 but it doesn't work anymore in 1.58.3. Changes done in #634 might have affected it.

@eranhirsch eranhirsch added bug Something isn't working typing Something type related labels Apr 15, 2024
@eranhirsch
Copy link
Collaborator

Thank you for reporting, I'll take a look

@eranhirsch eranhirsch self-assigned this Apr 15, 2024
eranhirsch added a commit that referenced this issue Apr 17, 2024
There was a bug with the typing in the dataLast version that slipped
through our testing. It prevented headless usage as an equality checker
for functions like differenceWith.

Fixes: #641
@TkDodo
Copy link
Collaborator

TkDodo commented Apr 17, 2024

🎉 This issue has been resolved in version 1.60.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released typing Something type related
Projects
None yet
3 participants