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