Skip to content

Commit

Permalink
refactor(content)!: ModuleReference -> ModuleStatement
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed May 14, 2024
1 parent 98a2b20 commit c9ea236
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 62 deletions.
6 changes: 3 additions & 3 deletions src/content/__tests__/content.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
ExportDeclaration,
Expression,
LiteralValue,
ModuleReference,
ModuleStatement,
Pattern,
Primitive,
RootChild,
Expand All @@ -35,8 +35,8 @@ describe('unit-d:content/Content', () => {
expectTypeOf<TestSubject>().extract<LiteralValue>().not.toBeNever()
})

it('should extract ModuleReference', () => {
expectTypeOf<TestSubject>().extract<ModuleReference>().not.toBeNever()
it('should extract ModuleStatement', () => {
expectTypeOf<TestSubject>().extract<ModuleStatement>().not.toBeNever()
})

it('should extract Pattern', () => {
Expand Down
36 changes: 0 additions & 36 deletions src/content/__tests__/module-reference.spec-d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/content/__tests__/root.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
Comment,
Decorator,
Directive,
ModuleReferenceMap,
StatementMap
} from '@flex-development/esast'
import type * as TestSubject from '../root'
Expand All @@ -25,10 +24,6 @@ describe('unit-d:content/root', () => {
})

describe('RootMap', () => {
it('should extend ModuleReferenceMap', () => {
expectTypeOf<TestSubject.RootMap>().toMatchTypeOf<ModuleReferenceMap>()
})

it('should extend StatementMap', () => {
expectTypeOf<TestSubject.RootMap>().toMatchTypeOf<StatementMap>()
})
Expand Down
36 changes: 36 additions & 0 deletions src/content/__tests__/statement-module.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file Type Tests - moduleStatement
* @module esast/content/tests/unit-d/moduleStatement
*/

import type { NodeObject } from '#tests/types'
import type {
ExportDeclaration,
ImportDeclaration
} from '@flex-development/esast'
import type * as TestSubject from '../statement-module'

describe('unit-d:content/moduleStatement', () => {
describe('ModuleStatement', () => {
it('should equal ModuleStatementMap[keyof ModuleStatementMap]', () => {
// Arrange
type K = keyof TestSubject.ModuleStatementMap
type Expect = TestSubject.ModuleStatementMap[K]

// Expect
expectTypeOf<TestSubject.ModuleStatement>().toEqualTypeOf<Expect>
})
})

describe('ModuleStatementMap', () => {
it('should match NodeObject<ExportDeclaration>', () => {
expectTypeOf<TestSubject.ModuleStatementMap>()
.toMatchTypeOf<NodeObject<ExportDeclaration>>()
})

it('should match NodeObject<ImportDeclaration>', () => {
expectTypeOf<TestSubject.ModuleStatementMap>()
.toMatchTypeOf<NodeObject<ImportDeclaration>>()
})
})
})
6 changes: 6 additions & 0 deletions src/content/__tests__/statement.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
ForStatement,
IfStatement,
LabeledStatement,
ModuleStatementMap,
ReturnStatement,
StaticBlock,
SwitchStatement,
Expand All @@ -41,6 +42,11 @@ describe('unit-d:content/statement', () => {
expectTypeOf<TestSubject.StatementMap>().toMatchTypeOf<DeclarationMap>()
})

it('should extend ModuleStatementMap', () => {
expectTypeOf<TestSubject.StatementMap>()
.toMatchTypeOf<ModuleStatementMap>()
})

it('should match NodeObject<BlockStatement>', () => {
expectTypeOf<TestSubject.StatementMap>()
.toMatchTypeOf<NodeObject<BlockStatement>>()
Expand Down
2 changes: 1 addition & 1 deletion src/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type * from './expression-atomic'
export type * from './expression-subscript'
export type * from './expression-type'
export type * from './literal'
export type * from './module-reference'
export type * from './node'
export type * from './pattern'
export type * from './primitive'
export type * from './root'
export type * from './statement'
export type * from './statement-module'
4 changes: 1 addition & 3 deletions src/content/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
Comment,
Decorator,
Directive,
ModuleReferenceMap,
StatementMap
} from '@flex-development/esast'

Expand All @@ -32,10 +31,9 @@ type RootChild = RootMap[keyof RootMap]
* }
* }
*
* @extends {ModuleReferenceMap}
* @extends {StatementMap}
*/
interface RootMap extends ModuleReferenceMap, StatementMap {
interface RootMap extends StatementMap {
comment: Comment
decorator: Decorator
directive: Directive
Expand Down
20 changes: 10 additions & 10 deletions src/content/module-reference.ts → src/content/statement-module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Content - moduleReference
* @module esast/content/moduleReference
* @file Content - moduleStatement
* @module esast/content/moduleStatement
*/

import type {
Expand All @@ -9,30 +9,30 @@ import type {
} from '@flex-development/esast'

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

/**
* Registry of nodes that can occur where a {@linkcode ModuleReference} is
* Registry of nodes that can occur where a {@linkcode ModuleStatement} is
* expected.
*
* This interface can be augmented to register custom node types.
*
* @example
* declare module '@flex-development/esast' {
* interface ModuleReferenceMap {
* customModuleReference: CustomModuleReference
* interface ModuleStatementMap {
* customModuleStatement: CustomModuleStatement
* }
* }
*/
interface ModuleReferenceMap {
interface ModuleStatementMap {
exportDeclaration: ExportDeclaration
importDeclaration: ImportDeclaration
}

export type { ModuleReference, ModuleReferenceMap }
export type { ModuleStatement, ModuleStatementMap }
4 changes: 3 additions & 1 deletion src/content/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
ForStatement,
IfStatement,
LabeledStatement,
ModuleStatementMap,
ReturnStatement,
StaticBlock,
SwitchStatement,
Expand Down Expand Up @@ -47,8 +48,9 @@ type Statement = StatementMap[keyof StatementMap]
* }
*
* @extends {DeclarationMap}
* @extends ModuleStatementMap
*/
interface StatementMap extends DeclarationMap {
interface StatementMap extends DeclarationMap, ModuleStatementMap {
blockStatement: BlockStatement
breakStatement: BreakStatement
continueStatement: ContinueStatement
Expand Down
4 changes: 1 addition & 3 deletions src/nodes/module-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
Comment,
Data,
Directive,
ModuleReference,
Parent,
Statement
} from '@flex-development/esast'
Expand All @@ -34,10 +33,9 @@ interface ModuleBody extends Parent {
*
* @see {@linkcode Comment}
* @see {@linkcode Directive}
* @see {@linkcode ModuleReference}
* @see {@linkcode Statement}
*/
children: (Comment | Directive | ModuleReference | Statement)[]
children: (Comment | Directive | Statement)[]

/**
* Info from the ecosystem.
Expand Down

0 comments on commit c9ea236

Please sign in to comment.