-
-
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
df660e8
commit 1cc2097
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 - IfNever | ||
* @module tutils/types/tests/unit-d/IfNever | ||
*/ | ||
|
||
import type TestSubject from '../if-never' | ||
|
||
describe('unit-d:types/IfNever', () => { | ||
type False = false | ||
type True = true | ||
|
||
it('should equal False if IsNever<T> extends false', () => { | ||
expectTypeOf<TestSubject<never[], True, False>>().toEqualTypeOf<False>() | ||
}) | ||
|
||
it('should equal True if IsNever<T> extends true', () => { | ||
expectTypeOf<TestSubject<never, 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 - IsNever | ||
* @module tutils/types/tests/unit-d/IsNever | ||
*/ | ||
|
||
import type TestSubject from '../is-never' | ||
|
||
describe('unit-d:types/IsNever', () => { | ||
it('should equal false if [T] does not extend [never]', () => { | ||
expectTypeOf<TestSubject<bigint>>().toEqualTypeOf<false>() | ||
}) | ||
|
||
it('should equal true if [T] extends [never]', () => { | ||
expectTypeOf<TestSubject<never>>().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 - IfNever | ||
* @module tutils/types/IfNever | ||
*/ | ||
|
||
import type IsNever from './is-never' | ||
|
||
/** | ||
* Conditional type that resolves depending on whether or not `T` is type | ||
* `never`. | ||
* | ||
* @see {@linkcode IsNever} | ||
* | ||
* @template T - Type to evaluate | ||
* @template True - Type if `T` is type `never` | ||
* @template False - Type if `T` is not type `never` | ||
*/ | ||
type IfNever<T, True, False> = IsNever<T> extends true ? True : False | ||
|
||
export type { IfNever 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 - IsNever | ||
* @module tutils/types/IsNever | ||
*/ | ||
|
||
/** | ||
* Returns a boolean indicating if `T` is type `never`. | ||
* | ||
* @template T - Type to evaluate | ||
*/ | ||
type IsNever<T> = [T] extends [never] ? true : false | ||
|
||
export type { IsNever as default } |