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

Export IsEqual type #346

Closed
sindresorhus opened this issue Jan 9, 2022 · 0 comments · Fixed by #522
Closed

Export IsEqual type #346

sindresorhus opened this issue Jan 9, 2022 · 0 comments · Fixed by #522
Labels
help wanted Extra attention is needed type addition

Comments

@sindresorhus
Copy link
Owner

/**
Returns a boolean for whether the two given types are equal.
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
*/
export type IsEqual<T, U> =
(<G>() => G extends T ? 1 : 2) extends
(<G>() => G extends U ? 1 : 2)
? true
: false;

I needs better docs and usage example.

Read: https://github.com/sindresorhus/type-fest/blob/main/.github/contributing.md#submitting-a-new-type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type addition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant