-
-
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):
Expression
, ExpressionMap
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
ce857ce
commit d49b280
Showing
3 changed files
with
67 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,31 @@ | ||
/** | ||
* @file Type Tests - expression | ||
* @module esast/content/tests/unit-d/expression | ||
*/ | ||
|
||
import type { Identifier, LiteralMap } from '@flex-development/esast' | ||
import type * as TestSubject from '../expression' | ||
|
||
describe('unit-d:content/expression', () => { | ||
describe('Expression', () => { | ||
it('should equal ExpressionMap[keyof ExpressionMap]', () => { | ||
// Arrange | ||
type Expect = TestSubject.ExpressionMap[keyof TestSubject.ExpressionMap] | ||
|
||
// Expect | ||
expectTypeOf<TestSubject.Expression>().toEqualTypeOf<Expect> | ||
}) | ||
}) | ||
|
||
describe('ExpressionMap', () => { | ||
it('should extend LiteralMap', () => { | ||
expectTypeOf<TestSubject.ExpressionMap>().toMatchTypeOf<LiteralMap>() | ||
}) | ||
|
||
it('should match [identifier: Identifier]', () => { | ||
expectTypeOf<TestSubject.ExpressionMap>() | ||
.toHaveProperty('identifier') | ||
.toEqualTypeOf<Identifier> | ||
}) | ||
}) | ||
}) |
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,35 @@ | ||
/** | ||
* @file Content - expression | ||
* @module esast/content/expression | ||
*/ | ||
|
||
import type { Identifier, LiteralMap } from '@flex-development/esast' | ||
|
||
/** | ||
* Union of registered esast nodes that can occur where an expression is | ||
* expected. | ||
* | ||
* To register custom esast nodes, augment {@linkcode ExpressionMap}. They will | ||
* be added to this union automatically. | ||
*/ | ||
type Expression = ExpressionMap[keyof ExpressionMap] | ||
|
||
/** | ||
* Registry of nodes that can occur where an {@linkcode Expression} is expected. | ||
* | ||
* This interface can be augmented to register custom node types. | ||
* | ||
* @example | ||
* declare module '@flex-development/docast' { | ||
* interface ExpressionMap { | ||
* customExpression: CustomExpression | ||
* } | ||
* } | ||
* | ||
* @extends {LiteralMap} | ||
*/ | ||
interface ExpressionMap extends LiteralMap { | ||
identifier: Identifier | ||
} | ||
|
||
export type { Expression, ExpressionMap } |
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