From c094738879a7183ca8f67a401fb45063f7eee595 Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Tue, 14 May 2024 07:04:33 -0400 Subject: [PATCH] refactor(content)!: `ModuleReference` -> `ModuleStatement` Signed-off-by: Lexus Drumgold --- src/content/__tests__/content.spec-d.ts | 6 ++-- .../__tests__/module-reference.spec-d.ts | 36 ------------------- src/content/__tests__/root.spec-d.ts | 5 --- .../__tests__/statement-module.spec-d.ts | 36 +++++++++++++++++++ src/content/__tests__/statement.spec-d.ts | 6 ++++ src/content/index.ts | 2 +- src/content/root.ts | 4 +-- ...odule-reference.ts => statement-module.ts} | 20 +++++------ src/content/statement.ts | 4 ++- src/nodes/module-body.ts | 4 +-- 10 files changed, 61 insertions(+), 62 deletions(-) delete mode 100644 src/content/__tests__/module-reference.spec-d.ts create mode 100644 src/content/__tests__/statement-module.spec-d.ts rename src/content/{module-reference.ts => statement-module.ts} (50%) diff --git a/src/content/__tests__/content.spec-d.ts b/src/content/__tests__/content.spec-d.ts index 10a92c1..3687c6d 100644 --- a/src/content/__tests__/content.spec-d.ts +++ b/src/content/__tests__/content.spec-d.ts @@ -8,7 +8,7 @@ import type { ExportDeclaration, Expression, LiteralValue, - ModuleReference, + ModuleStatement, Pattern, Primitive, RootChild, @@ -35,8 +35,8 @@ describe('unit-d:content/Content', () => { expectTypeOf().extract().not.toBeNever() }) - it('should extract ModuleReference', () => { - expectTypeOf().extract().not.toBeNever() + it('should extract ModuleStatement', () => { + expectTypeOf().extract().not.toBeNever() }) it('should extract Pattern', () => { diff --git a/src/content/__tests__/module-reference.spec-d.ts b/src/content/__tests__/module-reference.spec-d.ts deleted file mode 100644 index f8a4307..0000000 --- a/src/content/__tests__/module-reference.spec-d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file Type Tests - moduleReference - * @module esast/content/tests/unit-d/moduleReference - */ - -import type { NodeObject } from '#tests/types' -import type { - ExportDeclaration, - ImportDeclaration -} from '@flex-development/esast' -import type * as TestSubject from '../module-reference' - -describe('unit-d:content/moduleReference', () => { - describe('ModuleReference', () => { - it('should equal ModuleReferenceMap[keyof ModuleReferenceMap]', () => { - // Arrange - type K = keyof TestSubject.ModuleReferenceMap - type Expect = TestSubject.ModuleReferenceMap[K] - - // Expect - expectTypeOf().toEqualTypeOf - }) - }) - - describe('ModuleReferenceMap', () => { - it('should match NodeObject', () => { - expectTypeOf() - .toMatchTypeOf>() - }) - - it('should match NodeObject', () => { - expectTypeOf() - .toMatchTypeOf>() - }) - }) -}) diff --git a/src/content/__tests__/root.spec-d.ts b/src/content/__tests__/root.spec-d.ts index 15d1f7e..3de4297 100644 --- a/src/content/__tests__/root.spec-d.ts +++ b/src/content/__tests__/root.spec-d.ts @@ -8,7 +8,6 @@ import type { Comment, Decorator, Directive, - ModuleReferenceMap, StatementMap } from '@flex-development/esast' import type * as TestSubject from '../root' @@ -25,10 +24,6 @@ describe('unit-d:content/root', () => { }) describe('RootMap', () => { - it('should extend ModuleReferenceMap', () => { - expectTypeOf().toMatchTypeOf() - }) - it('should extend StatementMap', () => { expectTypeOf().toMatchTypeOf() }) diff --git a/src/content/__tests__/statement-module.spec-d.ts b/src/content/__tests__/statement-module.spec-d.ts new file mode 100644 index 0000000..50be99b --- /dev/null +++ b/src/content/__tests__/statement-module.spec-d.ts @@ -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().toEqualTypeOf + }) + }) + + describe('ModuleStatementMap', () => { + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + }) +}) diff --git a/src/content/__tests__/statement.spec-d.ts b/src/content/__tests__/statement.spec-d.ts index 3925782..b974339 100644 --- a/src/content/__tests__/statement.spec-d.ts +++ b/src/content/__tests__/statement.spec-d.ts @@ -18,6 +18,7 @@ import type { ForStatement, IfStatement, LabeledStatement, + ModuleStatementMap, ReturnStatement, StaticBlock, SwitchStatement, @@ -41,6 +42,11 @@ describe('unit-d:content/statement', () => { expectTypeOf().toMatchTypeOf() }) + it('should extend ModuleStatementMap', () => { + expectTypeOf() + .toMatchTypeOf() + }) + it('should match NodeObject', () => { expectTypeOf() .toMatchTypeOf>() diff --git a/src/content/index.ts b/src/content/index.ts index e4c74a5..237379f 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -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' diff --git a/src/content/root.ts b/src/content/root.ts index 01ecb24..e790415 100644 --- a/src/content/root.ts +++ b/src/content/root.ts @@ -7,7 +7,6 @@ import type { Comment, Decorator, Directive, - ModuleReferenceMap, StatementMap } from '@flex-development/esast' @@ -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 diff --git a/src/content/module-reference.ts b/src/content/statement-module.ts similarity index 50% rename from src/content/module-reference.ts rename to src/content/statement-module.ts index 3eb979b..06c434d 100644 --- a/src/content/module-reference.ts +++ b/src/content/statement-module.ts @@ -1,6 +1,6 @@ /** - * @file Content - moduleReference - * @module esast/content/moduleReference + * @file Content - moduleStatement + * @module esast/content/moduleStatement */ import type { @@ -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 } diff --git a/src/content/statement.ts b/src/content/statement.ts index cdfc89c..4208673 100644 --- a/src/content/statement.ts +++ b/src/content/statement.ts @@ -17,6 +17,7 @@ import type { ForStatement, IfStatement, LabeledStatement, + ModuleStatementMap, ReturnStatement, StaticBlock, SwitchStatement, @@ -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 diff --git a/src/nodes/module-body.ts b/src/nodes/module-body.ts index 060bc39..c8d3629 100644 --- a/src/nodes/module-body.ts +++ b/src/nodes/module-body.ts @@ -7,7 +7,6 @@ import type { Comment, Data, Directive, - ModuleReference, Parent, Statement } from '@flex-development/esast' @@ -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.