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

IsEqual #19749

Open
doz13189 opened this issue Nov 25, 2022 · 2 comments · May be fixed by #19750
Open

IsEqual #19749

doz13189 opened this issue Nov 25, 2022 · 2 comments · May be fixed by #19750
Labels
new-challenge Propose a new challenge, a PR will be auto generated

Comments

@doz13189
Copy link

doz13189 commented Nov 25, 2022

Please follow the template and fill the info. A PR will be auto-generated and always reflect on your changes.

Detailed solution/guide is not required, but please be sure the challenge is solvable.

Info

Basic info of your challenge questions,

difficulty: medium
title: IsEqual
tags: utils

Question

Implements the equal operator that returns a boolean for whether the two given types are equal.

For example:

type X1 = 1
type Y1 = 1
type T1 = IsEqual<X1, Y1> // expected to be true

type X2 = 1
type Y2 = 2
type T2 = IsEqual<X2, Y2> // expected to be false

Template

This is the template for challengers to start the coding. Basically, you just need to change the name of your generic/function and leave to implementation any.

type IsEqual<X, Y> = any

Test Cases

Provide some test cases for your challenge, you can use some utils from @type-challenges/utils for asserting.

import type { Equal, Expect } from '@type-challenges/utils'

type cases = [
  Expect<Equal<IsEqual<number, string>, false>>,
  Expect<Equal<IsEqual<1, 1>, true>>,
  Expect<Equal<IsEqual<any, 1>, false>>,
  Expect<Equal<IsEqual<1 | 2, 1>, false>>,
  Expect<Equal<IsEqual<any, never>, false>>,
  Expect<Equal<IsEqual<[any], [number]>, false>>,
]
@doz13189 doz13189 added the new-challenge Propose a new challenge, a PR will be auto generated label Nov 25, 2022
github-actions bot pushed a commit that referenced this issue Nov 25, 2022
@github-actions github-actions bot linked a pull request Nov 25, 2022 that will close this issue
@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2022

#19750 - Pull Request updated.

2022-11-25T09:43:37.681Z Preview in Playground

github-actions bot pushed a commit that referenced this issue Nov 25, 2022
@doz13189
Copy link
Author

doz13189 commented Nov 25, 2022

IsEqual expect the same as Equal for '@type-challenges/utils'.
Equal is used in some problems. for example #1568
So having 'Equal' in questions will help users to solve other questions.

github-actions bot pushed a commit that referenced this issue Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-challenge Propose a new challenge, a PR will be auto generated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant