-
-
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.
feat(content):
Declaration
, DeclarationMap
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
53190ff
commit 310368d
Showing
6 changed files
with
92 additions
and
2 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
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,36 @@ | ||
/** | ||
* @file Type Tests - declaration | ||
* @module esast/content/tests/unit-d/declaration | ||
*/ | ||
|
||
import type { NodeObject } from '#tests/types' | ||
import type { | ||
FunctionDeclaration, | ||
VariableDeclaration | ||
} from '@flex-development/esast' | ||
import type * as TestSubject from '../declaration' | ||
|
||
describe('unit-d:content/declaration', () => { | ||
describe('Declaration', () => { | ||
it('should equal DeclarationMap[keyof DeclarationMap]', () => { | ||
// Arrange | ||
type K = keyof TestSubject.DeclarationMap | ||
type Expect = TestSubject.DeclarationMap[K] | ||
|
||
// Expect | ||
expectTypeOf<TestSubject.Declaration>().toEqualTypeOf<Expect> | ||
}) | ||
}) | ||
|
||
describe('DeclarationMap', () => { | ||
it('should match NodeObject<FunctionDeclaration>', () => { | ||
expectTypeOf<TestSubject.DeclarationMap>() | ||
.toMatchTypeOf<NodeObject<FunctionDeclaration>>() | ||
}) | ||
|
||
it('should match NodeObject<VariableDeclaration>', () => { | ||
expectTypeOf<TestSubject.DeclarationMap>() | ||
.toMatchTypeOf<NodeObject<VariableDeclaration>>() | ||
}) | ||
}) | ||
}) |
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,37 @@ | ||
/** | ||
* @file Content - declaration | ||
* @module esast/content/declaration | ||
*/ | ||
|
||
import type { | ||
FunctionDeclaration, | ||
VariableDeclaration | ||
} from '@flex-development/esast' | ||
|
||
/** | ||
* Union of registered esast nodes that can occur where a non-module declaration | ||
* is expected. | ||
* | ||
* To register custom esast nodes, augment {@linkcode DeclarationMap}. | ||
* They will be added to this union automatically. | ||
*/ | ||
type Declaration = DeclarationMap[keyof DeclarationMap] | ||
|
||
/** | ||
* Registry of nodes that can occur where a {@linkcode Declaration} is expected. | ||
* | ||
* This interface can be augmented to register custom node types. | ||
* | ||
* @example | ||
* declare module '@flex-development/esast' { | ||
* interface DeclarationMap { | ||
* customDeclaration: CustomDeclaration | ||
* } | ||
* } | ||
*/ | ||
interface DeclarationMap { | ||
functionDeclaration: FunctionDeclaration | ||
variableDeclaration: VariableDeclaration | ||
} | ||
|
||
export type { Declaration, DeclarationMap } |
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