Skip to content

Commit

Permalink
feat(types): ParentType
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Mar 3, 2023
1 parent f28274d commit fa6d75b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/nodes/parent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* @module docast/nodes/Parent
*/

import type { Type } from '#src/enums'
import type { Child } from '#src/types'
import type { Child, ParentType } from '#src/types'
import type unist from 'unist'
import type Node from './node'

Expand Down Expand Up @@ -34,9 +33,9 @@ interface Parent<
/**
* Node variant.
*
* @see [`Type`]({@link ../enums/type.ts})
* @see [`ParentType`]({@link ../types/type-parent.ts})
*/
type: Type.BLOCK_TAG | Type.COMMENT | Type.IMPLICIT_DESCRIPTION | Type.ROOT
type: ParentType
}

export type { Parent as default }
27 changes: 27 additions & 0 deletions src/types/__tests__/type-parent.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file Type Tests - ParentType
* @module docast/types/tests/unit-d/ParentType
*/

import type { Type } from '#src/enums'
import type TestSubject from '../type-parent'

describe('unit-d:types/ParentType', () => {
it('should extract Type.BLOCK_TAG', () => {
expectTypeOf<TestSubject>().extract<Type.BLOCK_TAG>().toBeString()
})

it('should extract Type.COMMENT', () => {
expectTypeOf<TestSubject>().extract<Type.COMMENT>().toBeString()
})

it('should extract Type.IMPLICIT_DESCRIPTION', () => {
expectTypeOf<TestSubject>()
.extract<Type.IMPLICIT_DESCRIPTION>()
.toBeString()
})

it('should extract Type.ROOT', () => {
expectTypeOf<TestSubject>().extract<Type.ROOT>().toBeString()
})
})
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/

export type { default as Child } from './child'
export type { default as ParentType } from './type-parent'
19 changes: 19 additions & 0 deletions src/types/type-parent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @file Type Definitions - ParentType
* @module docast/types/ParentType
*/

import type { Type } from '#src/enums'

/**
* **Parent** ([**UnistParent**][1]) node types.
*
* [1]: https://github.com/syntax-tree/unist#parent
*/
type ParentType =
| Type.BLOCK_TAG
| Type.COMMENT
| Type.IMPLICIT_DESCRIPTION
| Type.ROOT

export type { ParentType as default }

0 comments on commit fa6d75b

Please sign in to comment.