-
-
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
0501d14
commit 298f43b
Showing
7 changed files
with
76 additions
and
1 deletion.
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
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 - IfFunction | ||
* @module tutils/types/tests/unit-d/IfFunction | ||
*/ | ||
|
||
import type Fn from '../fn' | ||
import type TestSubject from '../if-function' | ||
|
||
describe('unit-d:types/IfFunction', () => { | ||
type False = false | ||
type True = true | ||
|
||
it('should equal False if IsFunction<T> extends false', () => { | ||
expectTypeOf<TestSubject<Fn[], True, False>>().toEqualTypeOf<False>() | ||
}) | ||
|
||
it('should equal True if IsFunction<T> extends true', () => { | ||
expectTypeOf<TestSubject<Fn, 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 - IsFunction | ||
* @module tutils/types/tests/unit-d/IsFunction | ||
*/ | ||
|
||
import type Fn from '../fn' | ||
import type TestSubject from '../is-function' | ||
|
||
describe('unit-d:types/IsFunction', () => { | ||
it('should equal false if T does not extend Fn', () => { | ||
expectTypeOf<TestSubject<Date>>().toEqualTypeOf<false>() | ||
}) | ||
|
||
it('should equal true if T extends Fn', () => { | ||
expectTypeOf<TestSubject<Fn>>().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
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 - IfFunction | ||
* @module tutils/types/IfFunction | ||
*/ | ||
|
||
import type IsFunction from './is-function' | ||
|
||
/** | ||
* Conditional type that resolves depending on whether or not `T` extends | ||
* `Fn`. | ||
* | ||
* @see {@linkcode IsFunction} | ||
* | ||
* @template T - Type to evaluate | ||
* @template True - Type if `T` extends `Fn` | ||
* @template False - Type if `T` does not extend `Fn` | ||
*/ | ||
type IfFunction<T, True, False> = IsFunction<T> extends true ? True : False | ||
|
||
export type { IfFunction 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 - IsFunction | ||
* @module tutils/types/IsFunction | ||
*/ | ||
|
||
import type Fn from './fn' | ||
|
||
/** | ||
* Returns a boolean indicating if `T` extends {@linkcode Fn}. | ||
* | ||
* @template T - Type to evaluate | ||
*/ | ||
type IsFunction<T> = T extends Fn ? true : false | ||
|
||
export type { IsFunction as default } |