-
-
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
c07d58e
commit b63526d
Showing
5 changed files
with
69 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,19 @@ | ||
/** | ||
* @file Type Tests - IfAny | ||
* @module tutils/types/tests/unit-d/IfAny | ||
*/ | ||
|
||
import type TestSubject from '../if-any' | ||
|
||
describe('unit-d:types/IfAny', () => { | ||
type False = false | ||
type True = true | ||
|
||
it('should equal False if IsAny<T> extends false', () => { | ||
expectTypeOf<TestSubject<any[], True, False>>().toEqualTypeOf<False>() | ||
}) | ||
|
||
it('should equal True if IsAny<T> extends true', () => { | ||
expectTypeOf<TestSubject<any, True, False>>().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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file Type Tests - IsAny | ||
* @module tutils/types/tests/unit-d/IsAny | ||
*/ | ||
|
||
import type TestSubject from '../is-any' | ||
|
||
describe('unit-d:types/IsAny', () => { | ||
it('should equal false if T is not any', () => { | ||
expectTypeOf<TestSubject<number>>().toEqualTypeOf<false>() | ||
}) | ||
|
||
it('should equal true if T is any', () => { | ||
expectTypeOf<TestSubject<any>>().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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @file Type Definitions - IfAny | ||
* @module tutils/types/IfAny | ||
*/ | ||
|
||
import type IsAny from './is-any' | ||
|
||
/** | ||
* Conditional type that resolves depending on whether or not `T` is type `any`. | ||
* | ||
* @see {@linkcode IsAny} | ||
* | ||
* @template T - Type to evaluate | ||
* @template True - Type if `T` is type `any` | ||
* @template False - Type if `T` is not type `any` | ||
*/ | ||
type IfAny<T, True, False> = IsAny<T> extends true ? True : False | ||
|
||
export type { IfAny as default } |
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,13 @@ | ||
/** | ||
* @file Type Definitions - IsAny | ||
* @module tutils/types/IsAny | ||
*/ | ||
|
||
/** | ||
* Returns a boolean indicating if `T` is type `any`. | ||
* | ||
* @template T - Type to evaluate | ||
*/ | ||
type IsAny<T> = 0 extends T & 1 ? true : false | ||
|
||
export type { IsAny as default } |