-
-
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
8dbae2e
commit f849aeb
Showing
7 changed files
with
75 additions
and
4 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,34 @@ | ||
/** | ||
* @file Type Tests - root | ||
* @module esast/content/tests/unit-d/root | ||
*/ | ||
|
||
import type { NodeObject } from '#tests/types' | ||
import type { Comment, Directive, StatementMap } from '@flex-development/esast' | ||
import type * as TestSubject from '../root' | ||
|
||
describe('unit-d:content/root', () => { | ||
describe('RootChild', () => { | ||
it('should equal RootMap[keyof RootMap]', () => { | ||
// Arrange | ||
type Expect = TestSubject.RootMap[keyof TestSubject.RootMap] | ||
|
||
// Expect | ||
expectTypeOf<TestSubject.RootChild>().toEqualTypeOf<Expect> | ||
}) | ||
}) | ||
|
||
describe('RootMap', () => { | ||
it('should extend StatementMap', () => { | ||
expectTypeOf<TestSubject.RootMap>().toMatchTypeOf<StatementMap>() | ||
}) | ||
|
||
it('should match NodeObject<Comment>', () => { | ||
expectTypeOf<TestSubject.RootMap>().toMatchTypeOf<NodeObject<Comment>>() | ||
}) | ||
|
||
it('should match NodeObject<Directive>', () => { | ||
expectTypeOf<TestSubject.RootMap>().toMatchTypeOf<NodeObject<Directive>>() | ||
}) | ||
}) | ||
}) |
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
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
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,36 @@ | ||
/** | ||
* @file Content - root | ||
* @module esast/content/root | ||
*/ | ||
|
||
import type { Comment, Directive, StatementMap } from '@flex-development/esast' | ||
|
||
/** | ||
* Union of registered esast nodes that can occur where a root child node is | ||
* expected. | ||
* | ||
* To register custom esast nodes, augment {@linkcode RootMap}. They will | ||
* be added to this union automatically. | ||
*/ | ||
type RootChild = RootMap[keyof RootMap] | ||
|
||
/** | ||
* Registry of nodes that can occur where a {@linkcode RootChild} is expected. | ||
* | ||
* This interface can be augmented to register custom node types. | ||
* | ||
* @example | ||
* declare module '@flex-development/esast' { | ||
* interface RootMap { | ||
* customNode: CustomNode | ||
* } | ||
* } | ||
* | ||
* @extends {StatementMap} | ||
*/ | ||
interface RootMap extends StatementMap { | ||
comment: Comment | ||
directive: Directive | ||
} | ||
|
||
export type { RootChild, RootMap } |
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