-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
3307bbe
commit 58ddf01
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file Type Tests - VariableDeclarator | ||
* @module esast/nodes/tests/unit-d/VariableDeclarator | ||
*/ | ||
|
||
import type { Data, Expression, Parent, Pattern } from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../variable-declarator' | ||
|
||
describe('unit-d:nodes/VariableDeclarator', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.VariableDeclaratorData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: [Pattern, Expression] | [Pattern]]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('children') | ||
.toEqualTypeOf<[Pattern, Expression] | [Pattern]>() | ||
}) | ||
|
||
it('should match [data?: Optional<VariableDeclaratorData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "variableDeclarator"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'variableDeclarator'>() | ||
}) | ||
|
||
describe('VariableDeclaratorData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @file Nodes - VariableDeclarator | ||
* @module esast/nodes/VariableDeclarator | ||
*/ | ||
|
||
import type { Data, Expression, Parent, Pattern } from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with variable declarators. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface VariableDeclaratorData extends Data {} | ||
|
||
/** | ||
* A variable declarator. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface VariableDeclarator extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Expression} | ||
* @see {@linkcode Pattern} | ||
*/ | ||
children: [id: Pattern, init: Expression] | [id: Pattern] | ||
|
||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode VariableDeclaratorData} | ||
*/ | ||
data?: Optional<VariableDeclaratorData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'variableDeclarator' | ||
} | ||
|
||
export type { VariableDeclaratorData, VariableDeclarator as default } |