-
-
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
e2c2e89
commit 9f2fce4
Showing
4 changed files
with
51 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,17 @@ | ||
/** | ||
* @file Type Tests - Value | ||
* @module unist-util-types/tests/unit-d/Value | ||
*/ | ||
|
||
import type * as mdast from 'mdast' | ||
import type TestSubject from '../value' | ||
|
||
describe('unit-d:Value', () => { | ||
it('should equal T["value"]', () => { | ||
// Arrange | ||
type T = mdast.Text | ||
|
||
// Expect | ||
expectTypeOf<TestSubject<T>>().toEqualTypeOf<T['value']>() | ||
}) | ||
}) |
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,21 @@ | ||
/** | ||
* @file Value | ||
* @module unist-util-types/Value | ||
*/ | ||
|
||
import type { Literal, Node } from 'unist' | ||
|
||
/** | ||
* Extract the value of from [*tree*][1] `T`. | ||
* | ||
* [1]: https://github.com/syntax-tree/unist#tree | ||
* | ||
* @see {@linkcode Literal} | ||
* @see {@linkcode Node} | ||
* @see https://github.com/syntax-tree/unist#literal | ||
* | ||
* @template {Node} [T=Literal] - Tree to try extracting value from | ||
*/ | ||
type Value<T extends Node = Literal> = T extends Literal ? T['value'] : never | ||
|
||
export type { Value as default } |