Skip to content

Commit

Permalink
feat(nodes): MultiLineComment
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 8, 2024
1 parent 919c026 commit 31d233d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/nodes/__tests__/comment-multi-line.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file Type Tests - MultiLineComment
* @module esast/nodes/tests/unit-d/MultiLineComment
*/

import type { CommentData, Node } from '@flex-development/esast'
import type { Optional } from '@flex-development/tutils'
import type * as TestSubject from '../comment-multi-line'

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

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

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

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

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

describe('MultiLineCommentData', () => {
it('should extend CommentData', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<CommentData>()
})
})
})
44 changes: 44 additions & 0 deletions src/nodes/comment-multi-line.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @file Nodes - MultiLineComment
* @module esast/nodes/MultiLineComment
*/

import type { CommentData, Node } from '@flex-development/esast'
import type { Optional } from '@flex-development/tutils'

/**
* Info associated with multi line comments.
*
* @see {@linkcode CommentData}
*
* @extends {CommentData}
*/
interface MultiLineCommentData extends CommentData {}

/**
* A multi line comment.
*
* @see {@linkcode Node}
*
* @extends {Node}
*/
interface MultiLineComment extends Node {
/**
* Info from the ecosystem.
*
* @see {@linkcode MultiLineCommentData}
*/
data?: Optional<MultiLineCommentData>

/**
* Multi line comment marker.
*/
multi: true

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

export type { MultiLineCommentData, MultiLineComment as default }
4 changes: 4 additions & 0 deletions src/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export type {
default as DocblockComment,
DocblockCommentData
} from './comment-docblock'
export type {
default as MultiLineComment,
MultiLineCommentData
} from './comment-multi-line'
export type { default as Directive, DirectiveData } from './directive'
export type { default as Identifier, IdentifierData } from './identifier'
export type { default as DefaultIdentifier } from './identifier-default'
Expand Down

0 comments on commit 31d233d

Please sign in to comment.