Skip to content

Commit

Permalink
feat(nodes): NumberLiteral
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 7, 2024
1 parent 870e397 commit 04830dd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/nodes/__tests__/literal-number.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file Type Tests - NumberLiteral
* @module esast/nodes/tests/unit-d/NumberLiteral
*/

import type { Literal } from '@flex-development/esast'
import type TestSubject from '../literal-number'

describe('unit-d:nodes/NumberLiteral', () => {
it('should extend Literal', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<Literal>()
})

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

it('should match [value: number]', () => {
expectTypeOf<TestSubject>().toHaveProperty('value').toEqualTypeOf<number>()
})
})
1 change: 1 addition & 0 deletions src/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type { default as Literal } from './literal'
export type { default as BigIntLiteral } from './literal-bigint'
export type { default as BooleanLiteral } from './literal-boolean'
export type { default as NullLiteral } from './literal-null'
export type { default as NumberLiteral } from './literal-number'
export type { default as Node } from './node'
27 changes: 27 additions & 0 deletions src/nodes/literal-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file Nodes - NumberLiteral
* @module esast/nodes/NumberLiteral
*/

import type { Literal } from '@flex-development/esast'

/**
* A literal integer or floating point number.
*
* @see {@linkcode Literal}
*
* @extends {Literal}
*/
interface NumberLiteral extends Literal {
/**
* Node type.
*/
type: 'number'

/**
* Plain value.
*/
value: number
}

export type { NumberLiteral as default }

0 comments on commit 04830dd

Please sign in to comment.