-
-
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
1cc2097
commit d132941
Showing
5 changed files
with
73 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,20 @@ | ||
/** | ||
* @file Type Tests - IfNil | ||
* @module tutils/types/tests/unit-d/IfNil | ||
*/ | ||
|
||
import type TestSubject from '../if-nil' | ||
import type NIL from '../nil' | ||
|
||
describe('unit-d:types/IfNil', () => { | ||
type False = false | ||
type True = true | ||
|
||
it('should equal False if IsNil<T> extends false', () => { | ||
expectTypeOf<TestSubject<NIL[], True, False>>().toEqualTypeOf<False>() | ||
}) | ||
|
||
it('should equal True if IsNil<T> extends true', () => { | ||
expectTypeOf<TestSubject<NIL, 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,17 @@ | ||
/** | ||
* @file Type Tests - IsNil | ||
* @module tutils/types/tests/unit-d/IsNil | ||
*/ | ||
|
||
import type TestSubject from '../is-nil' | ||
import type NIL from '../nil' | ||
|
||
describe('unit-d:types/IsNil', () => { | ||
it('should equal false if T does not extend NIL', () => { | ||
expectTypeOf<TestSubject<bigint>>().toEqualTypeOf<false>() | ||
}) | ||
|
||
it('should equal true if T extends NIL', () => { | ||
expectTypeOf<TestSubject<NIL>>().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 - IfNil | ||
* @module tutils/types/IfNil | ||
*/ | ||
|
||
import type IsNil from './is-nil' | ||
|
||
/** | ||
* Conditional type that resolves depending on whether or not `T` extends `NIL`. | ||
* | ||
* @see {@linkcode IsNil} | ||
* | ||
* @template T - Type to evaluate | ||
* @template True - Type if `T` is `nil` | ||
* @template False - Type if `T` is not `nil` | ||
*/ | ||
type IfNil<T, True, False> = IsNil<T> extends true ? True : False | ||
|
||
export type { IfNil 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,15 @@ | ||
/** | ||
* @file Type Definitions - IsNil | ||
* @module tutils/types/IsNil | ||
*/ | ||
|
||
import type NIL from './nil' | ||
|
||
/** | ||
* Returns a boolean indicating if `T` extends {@linkcode NIL}. | ||
* | ||
* @template T - Type to evaluate | ||
*/ | ||
type IsNil<T> = T extends NIL ? true : false | ||
|
||
export type { IsNil as default } |