-
-
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.
feat(content):
LiteralMap
, LiteralValue
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
7b527dd
commit 70bae5f
Showing
3 changed files
with
65 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,28 @@ | ||
/** | ||
* @file Type Tests - literal | ||
* @module esast/content/tests/unit-d/literal | ||
*/ | ||
|
||
import type { PrimitiveMap, RegExpLiteral } from '@flex-development/esast' | ||
import type * as TestSubject from '../literal' | ||
|
||
describe('unit-d:content/literal', () => { | ||
describe('LiteralMap', () => { | ||
it('should extend PrimitiveMap', () => { | ||
expectTypeOf<TestSubject.LiteralMap>().toMatchTypeOf<PrimitiveMap>() | ||
}) | ||
|
||
it('should match [regexp: RegExpLiteral]', () => { | ||
expectTypeOf<TestSubject.LiteralMap>() | ||
.toHaveProperty('regexp') | ||
.toEqualTypeOf<RegExpLiteral> | ||
}) | ||
}) | ||
|
||
describe('LiteralValue', () => { | ||
it('should equal LiteralMap[keyof LiteralMap]', () => { | ||
expectTypeOf<TestSubject.LiteralValue>() | ||
.toEqualTypeOf<TestSubject.LiteralMap[keyof TestSubject.LiteralMap]> | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
* @module esast/content | ||
*/ | ||
|
||
export type * from './literal' | ||
export type * from './primitive' |
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 - literal | ||
* @module esast/content/literal | ||
*/ | ||
|
||
import type { PrimitiveMap, RegExpLiteral } from '@flex-development/esast' | ||
|
||
/** | ||
* Union of registered esast nodes that can occur where a literal value is | ||
* expected. | ||
* | ||
* To register custom esast nodes, augment {@linkcode LiteralMap}. They will be | ||
* added to this union automatically. | ||
*/ | ||
type LiteralValue = LiteralMap[keyof LiteralMap] | ||
|
||
/** | ||
* Registry of nodes that can occur where a {@linkcode LiteralValue} is | ||
* expected. | ||
* | ||
* This interface can be augmented to register custom node types. | ||
* | ||
* @example | ||
* declare module '@flex-development/docast' { | ||
* interface LiteralMap { | ||
* custom: CustomLiteral | ||
* } | ||
* } | ||
* | ||
* @extends {PrimitiveMap} | ||
*/ | ||
interface LiteralMap extends PrimitiveMap { | ||
regexp: RegExpLiteral | ||
} | ||
|
||
export type { LiteralMap, LiteralValue } |