Skip to content

Commit

Permalink
refactor(nodes)!: function data
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Apr 27, 2024
1 parent 90d29a6 commit 17ec3f1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 58 deletions.
22 changes: 9 additions & 13 deletions src/nodes/__tests__/declaration-function.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type { Data, Parent } from '@flex-development/esast'
import type { Nilable, Optional } from '@flex-development/tutils'
import type { Optional } from '@flex-development/tutils'
import type * as TestSubject from '../declaration-function'

describe('unit-d:nodes/FunctionDeclaration', () => {
Expand All @@ -15,12 +15,20 @@ describe('unit-d:nodes/FunctionDeclaration', () => {
expectTypeOf<Subject>().toMatchTypeOf<Parent>()
})

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

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

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

it('should match [type: "functionDeclaration"]', () => {
expectTypeOf<Subject>()
.toHaveProperty('type')
Expand All @@ -31,17 +39,5 @@ describe('unit-d:nodes/FunctionDeclaration', () => {
it('should extend Data', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<Data>()
})

it('should match [async?: Nilable<boolean>]', () => {
expectTypeOf<SubjectData>()
.toHaveProperty('async')
.toEqualTypeOf<Nilable<boolean>>()
})

it('should match [generator?: Nilable<boolean>]', () => {
expectTypeOf<SubjectData>()
.toHaveProperty('generator')
.toEqualTypeOf<Nilable<boolean>>()
})
})
})
22 changes: 9 additions & 13 deletions src/nodes/__tests__/expression-function.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type { Data, Parent } from '@flex-development/esast'
import type { Nilable, Optional } from '@flex-development/tutils'
import type { Optional } from '@flex-development/tutils'
import type * as TestSubject from '../expression-function'

describe('unit-d:nodes/FunctionExpression', () => {
Expand All @@ -15,12 +15,20 @@ describe('unit-d:nodes/FunctionExpression', () => {
expectTypeOf<Subject>().toMatchTypeOf<Parent>()
})

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

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

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

it('should match [type: "functionExpression"]', () => {
expectTypeOf<Subject>()
.toHaveProperty('type')
Expand All @@ -31,17 +39,5 @@ describe('unit-d:nodes/FunctionExpression', () => {
it('should extend Data', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<Data>()
})

it('should match [async?: Nilable<boolean>]', () => {
expectTypeOf<SubjectData>()
.toHaveProperty('async')
.toEqualTypeOf<Nilable<boolean>>()
})

it('should match [generator?: Nilable<boolean>]', () => {
expectTypeOf<SubjectData>()
.toHaveProperty('generator')
.toEqualTypeOf<Nilable<boolean>>()
})
})
})
32 changes: 16 additions & 16 deletions src/nodes/declaration-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
TypeAnnotation,
TypeParameterList
} from '@flex-development/esast'
import type { Nilable, Optional } from '@flex-development/tutils'
import type { Optional } from '@flex-development/tutils'

/**
* Info associated with function declarations.
Expand All @@ -23,21 +23,7 @@ import type { Nilable, Optional } from '@flex-development/tutils'
*
* @extends {Data}
*/
interface FunctionDeclarationData extends Data {
/**
* Asynchronous function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/async_function
*/
async?: Nilable<boolean>

/**
* Generator function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function*
*/
generator?: Nilable<boolean>
}
interface FunctionDeclarationData extends Data {}

/**
* A `function` declaration.
Expand All @@ -47,6 +33,13 @@ interface FunctionDeclarationData extends Data {
* @extends {Parent}
*/
interface FunctionDeclaration extends Parent {
/**
* Asynchronous function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/async_function
*/
async: boolean

/**
* List of children.
*
Expand Down Expand Up @@ -106,6 +99,13 @@ interface FunctionDeclaration extends Parent {
*/
data?: Optional<FunctionDeclarationData>

/**
* Generator function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function*
*/
generator: boolean

/**
* Node type.
*/
Expand Down
32 changes: 16 additions & 16 deletions src/nodes/expression-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
TypeAnnotation,
TypeParameterList
} from '@flex-development/esast'
import type { Nilable, Optional } from '@flex-development/tutils'
import type { Optional } from '@flex-development/tutils'

/**
* Info associated with function expressions.
Expand All @@ -23,21 +23,7 @@ import type { Nilable, Optional } from '@flex-development/tutils'
*
* @extends {Data}
*/
interface FunctionExpressionData extends Data {
/**
* Asynchronous function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/async_function
*/
async?: Nilable<boolean>

/**
* Generator function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/function*
*/
generator?: Nilable<boolean>
}
interface FunctionExpressionData extends Data {}

/**
* A `function` expression.
Expand All @@ -47,6 +33,13 @@ interface FunctionExpressionData extends Data {
* @extends {Parent}
*/
interface FunctionExpression extends Parent {
/**
* Asynchronous function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/async_function
*/
async: boolean

/**
* List of children.
*
Expand Down Expand Up @@ -138,6 +131,13 @@ interface FunctionExpression extends Parent {
*/
data?: Optional<FunctionExpressionData>

/**
* Generator function?
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/function*
*/
generator: boolean

/**
* Node type.
*/
Expand Down

0 comments on commit 17ec3f1

Please sign in to comment.