-
-
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 <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
e00904b
commit 36aa5f8
Showing
3 changed files
with
36 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,17 @@ | ||
/** | ||
* @file Type Tests - TypeGuard | ||
* @module tutils/types/tests/unit-d/TypeGuard | ||
*/ | ||
|
||
import type Vehicle from '#fixtures/types/vehicle' | ||
import type TestSubject from '../type-guard' | ||
|
||
describe('unit-d:types/TypeGuard', () => { | ||
it('should guard T', () => { | ||
// Arrange | ||
type T = Vehicle | ||
|
||
// Expect | ||
expectTypeOf<TestSubject<T>>().guards.toEqualTypeOf<T>() | ||
}) | ||
}) |
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,18 @@ | ||
/** | ||
* @file Type Definitions - TypeGuard | ||
* @module tutils/types/TypeGuard | ||
*/ | ||
|
||
/** | ||
* Checks if `value` is of type `T`. | ||
* | ||
* @see https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards | ||
* | ||
* @template T - Guarded value type | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is T} `true` if `value` is of type `T`, `false` otherwise | ||
*/ | ||
type TypeGuard<T> = (value: unknown) => value is T | ||
|
||
export type { TypeGuard as default } |