-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
35fdbd3
commit 118ddc6
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @file Type Tests - IsEqual | ||
* @module tutils/types/tests/unit-d/IsEqual | ||
*/ | ||
|
||
import type TestSubject from '../is-equal' | ||
|
||
describe('unit-d:types/IsEqual', () => { | ||
it('should equal false A and B are not equal', () => { | ||
expectTypeOf<TestSubject<0, 1>>().toEqualTypeOf<false>() | ||
expectTypeOf<TestSubject<20, { limit: 20 }>>().toEqualTypeOf<false>() | ||
}) | ||
|
||
it('should equal true if A and B are equal', () => { | ||
expectTypeOf<TestSubject<13, 13>>().toEqualTypeOf<true>() | ||
expectTypeOf<TestSubject<[1, 2], [1, 2]>>().toEqualTypeOf<true>() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @file Type Definitions - IsEqual | ||
* @module tutils/types/IsEqual | ||
*/ | ||
|
||
/** | ||
* Returns a boolean indicating if `A` and `B` are equal. | ||
* | ||
* @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 | ||
* @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 | ||
* | ||
* @template A - First type to evaluate | ||
* @template B - Second type to evaluate | ||
*/ | ||
type IsEqual<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B | ||
? 1 | ||
: 2 | ||
? true | ||
: false | ||
|
||
export type { IsEqual as default } |