Skip to content

Commit

Permalink
feat(content): Statement, StatementMap
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Mar 7, 2024
1 parent 8072fbd commit 39f0a77
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/content/__tests__/statement.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file Type Tests - statement
* @module esast/content/tests/unit-d/statement
*/

import type { EmptyStatement } from '@flex-development/esast'
import type * as TestSubject from '../statement'

describe('unit-d:content/statement', () => {
describe('Statement', () => {
it('should equal StatementMap[keyof StatementMap]', () => {
expectTypeOf<TestSubject.Statement>()
.toEqualTypeOf<TestSubject.StatementMap[keyof TestSubject.StatementMap]>
})
})

describe('StatementMap', () => {
it('should match [emptyStatement: EmptyStatement]', () => {
expectTypeOf<TestSubject.StatementMap>()
.toHaveProperty('emptyStatement')
.toEqualTypeOf<EmptyStatement>
})
})
})
1 change: 1 addition & 0 deletions src/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

export type * from './literal'
export type * from './primitive'
export type * from './statement'
32 changes: 32 additions & 0 deletions src/content/statement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file Content - statement
* @module esast/content/statement
*/

import type { EmptyStatement } from '@flex-development/esast'

/**
* Union of registered esast nodes that can occur where a statement is expected.
*
* To register custom esast nodes, augment {@linkcode StatementMap}. They will
* be added to this union automatically.
*/
type Statement = StatementMap[keyof StatementMap]

/**
* Registry of nodes that can occur where a {@linkcode Statement} is expected.
*
* This interface can be augmented to register custom node types.
*
* @example
* declare module '@flex-development/docast' {
* interface StatementMap {
* customStatement: CustomStatement
* }
* }
*/
interface StatementMap {
emptyStatement: EmptyStatement
}

export type { Statement, StatementMap }

0 comments on commit 39f0a77

Please sign in to comment.