Skip to content

Commit

Permalink
feat(nodes): ExportDefaultDeclaration
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 9, 2024
1 parent a7bd70e commit 09336a1
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/nodes/__tests__/declaration-export-default.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @file Type Tests - ExportDefaultDeclaration
* @module esast/nodes/tests/unit-d/ExportDefaultDeclaration
*/

import type {
ClassDeclaration,
Data,
Expression,
FunctionDeclaration,
Parent
} from '@flex-development/esast'
import type { Optional } from '@flex-development/tutils'
import type * as TestSubject from '../declaration-export-default'

describe('unit-d:nodes/ExportDefaultDeclaration', () => {
type Subject = TestSubject.default
type SubjectData = TestSubject.ExportDefaultDeclarationData

it('should extend Parent', () => {
expectTypeOf<Subject>().toMatchTypeOf<Parent>()
})

it('should match [children: [ClassDeclaration | Expression | FunctionDeclaration]]', () => {
expectTypeOf<Subject>()
.toHaveProperty('children')
.toEqualTypeOf<[ClassDeclaration | Expression | FunctionDeclaration]>()
})

it('should match [data?: Optional<ExportDefaultDeclarationData>]', () => {
expectTypeOf<Subject>()
.toHaveProperty('data')
.toEqualTypeOf<Optional<SubjectData>>()
})

it('should match [type: "exportDefaultDeclaration"]', () => {
expectTypeOf<Subject>()
.toHaveProperty('type')
.toEqualTypeOf<'exportDefaultDeclaration'>()
})

describe('ExportDefaultDeclarationData', () => {
it('should extend Data', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<Data>()
})
})
})
57 changes: 57 additions & 0 deletions src/nodes/declaration-export-default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @file Nodes - ExportDefaultDeclaration
* @module esast/nodes/ExportDefaultDeclaration
*/

import type {
ClassDeclaration,
Data,
Expression,
FunctionDeclaration,
Parent
} from '@flex-development/esast'
import type { Optional } from '@flex-development/tutils'

/**
* Info associated with default `export` declarations.
*
* @see {@linkcode Data}
*
* @extends {Data}
*/
interface ExportDefaultDeclarationData extends Data {}

/**
* A default `export` declaration.
*
* @see {@linkcode Parent}
*
* @extends {Parent}
*/
interface ExportDefaultDeclaration extends Parent {
/**
* List of children.
*
* @see {@linkcode ClassDeclaration}
* @see {@linkcode Expression}
* @see {@linkcode FunctionDeclaration}
*/
children: [declaration: ClassDeclaration | Expression | FunctionDeclaration]

/**
* Info from the ecosystem.
*
* @see {@linkcode ExportDefaultDeclarationData}
*/
data?: Optional<ExportDefaultDeclarationData>

/**
* Node type.
*/
type: 'exportDefaultDeclaration'
}

export type {
ExportDefaultDeclarationData,
ExportDefaultDeclaration as default
}
4 changes: 4 additions & 0 deletions src/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export type {
default as ExportAllDeclaration,
ExportAllDeclarationData
} from './declaration-export-all'
export type {
default as ExportDefaultDeclaration,
ExportDefaultDeclarationData
} from './declaration-export-default'
export type {
default as FunctionDeclaration,
FunctionDeclarationData
Expand Down

0 comments on commit 09336a1

Please sign in to comment.