-
-
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
02d8ba7
commit 59d4e0e
Showing
3 changed files
with
42 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 - IfTuple | ||
* @module tutils/types/tests/unit-d/IfTuple | ||
*/ | ||
|
||
import type TestSubject from '../if-tuple' | ||
|
||
describe('unit-d:types/IfTuple', () => { | ||
type False = false | ||
type True = true | ||
|
||
it('should equal False if IsTuple<T> extends false', () => { | ||
expectTypeOf<TestSubject<number[], True, False>>().toEqualTypeOf<False>() | ||
}) | ||
|
||
it('should equal True if IsTuple<T> extends true', () => { | ||
expectTypeOf<TestSubject<[0, 1, 2], 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,22 @@ | ||
/** | ||
* @file Type Definitions - IfTuple | ||
* @module tutils/types/IfTuple | ||
*/ | ||
|
||
import type IsTuple from './is-tuple' | ||
|
||
/** | ||
* Conditional type that resolves depending on whether or not `T` is a | ||
* [tuple][1] type. | ||
* | ||
* [1]: https://www.codecademy.com/resources/docs/typescript/tuples | ||
* | ||
* @see {@linkcode IsTuple} | ||
* | ||
* @template T - Type to evaluate | ||
* @template True - Type if `T` is tuple type | ||
* @template False - Type if `T` is not tuple type | ||
*/ | ||
type IfTuple<T, True, False> = IsTuple<T> extends true ? True : False | ||
|
||
export type { IfTuple 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