File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @file Type Tests - node
3+ * @module fst/content/tests/unit-d/node
4+ */
5+
6+ import type * as TestSubject from '#content/node'
7+ import type { AnyNode } from '@flex-development/fst'
8+ import type { Type } from '@flex-development/unist-util-types'
9+
10+ describe ( 'unit-d:content/node' , ( ) => {
11+ describe ( 'FstNode' , ( ) => {
12+ it ( 'should equal NodeMap[keyof NodeMap]' , ( ) => {
13+ // Arrange
14+ type K = keyof TestSubject . NodeMap
15+ type Expect = TestSubject . NodeMap [ K ]
16+
17+ // Expect
18+ expectTypeOf < TestSubject . FstNode > ( ) . toEqualTypeOf < Expect > ( )
19+ } )
20+ } )
21+
22+ describe ( 'NodeMap' , ( ) => {
23+ it ( 'should register all fst nodes' , ( ) => {
24+ // Arrange
25+ type Subject = TestSubject . NodeMap [ keyof TestSubject . NodeMap ]
26+
27+ // Expect
28+ expectTypeOf < Subject > ( ) . toEqualTypeOf < AnyNode > ( )
29+ expectTypeOf < keyof TestSubject . NodeMap > ( ) . toEqualTypeOf < Type < AnyNode > > ( )
30+ } )
31+ } )
32+ } )
Original file line number Diff line number Diff line change 44 */
55
66export type * from '#content/directory'
7+ export type * from '#content/node'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Content - node
3+ * @module fst/content/node
4+ */
5+
6+ import type {
7+ DirectoryContentMap ,
8+ Root
9+ } from '@flex-development/fst'
10+
11+ /**
12+ * Union of registered fst nodes.
13+ *
14+ * To register custom fst nodes, augment {@linkcode NodeMap}. They will be
15+ * added to this union automatically.
16+ */
17+ type FstNode = NodeMap [ keyof NodeMap ]
18+
19+ /**
20+ * Registry of fst nodes.
21+ *
22+ * This interface can be augmented to register custom nodes.
23+ *
24+ * @example
25+ * declare module '@flex-development/fst' {
26+ * interface NodeMap {
27+ * customNode: CustomNode
28+ * }
29+ * }
30+ *
31+ * @extends {DirectoryContentMap }
32+ */
33+ interface NodeMap extends DirectoryContentMap {
34+ root : Root
35+ }
36+
37+ export type { FstNode , NodeMap }
You can’t perform that action at this time.
0 commit comments