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

Add IsEqual type #522

Merged
merged 11 commits into from Dec 25, 2022
Merged

Add IsEqual type #522

merged 11 commits into from Dec 25, 2022

Conversation

doz13189
Copy link
Contributor

Close #346

source/is-equal.d.ts Outdated Show resolved Hide resolved
source/is-equal.d.ts Show resolved Hide resolved
source/is-equal.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

source/is-equal.d.ts Outdated Show resolved Hide resolved
source/is-equal.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

@doz13189
Copy link
Contributor Author

https://github.com/sindresorhus/type-fest/pull/522/files#r1033002320 still needs to be done

Sorry, I misread.
401ad60

@sindresorhus sindresorhus merged commit e5a3a57 into sindresorhus:main Dec 25, 2022
@trevorade
Copy link
Contributor

FYI

There are two self-identity bugs that can pretty simply be fixed: TS Playground

Both of these evaluate to false:

IsEqual<{a: 1} & {a: 1}, {a: 1}>
IsEqual<{a: 1} | {a: 1}, {a: 1}>

The fix is to expand the check a touch:

type IsEqual<A, B> =
    (<G>() => G extends A & G | G ? 1 : 2) extends
    (<G>() => G extends B & G | G ? 1 : 2)
    ? true
    : false;

There's also this bug but I'm unaware of a fix: TS Playground

This evaluates to false:

IsEqual<{a: 1} & {b: 2}, {a: 1, b: 2}>

@sindresorhus
Copy link
Owner

@trevorade Would you mind moving this to an issue instead? Otherwise it will be forgotten.

@trevorade
Copy link
Contributor

@trevorade Would you mind moving this to an issue instead? Otherwise it will be forgotten.

Created #537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export IsEqual type
3 participants