-
-
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):
PrimitiveMap
, Primitive
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
423d0bf
commit 7b527dd
Showing
5 changed files
with
114 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
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,61 @@ | ||
/** | ||
* @file Type Tests - primitive | ||
* @module esast/content/tests/unit-d/primitive | ||
*/ | ||
|
||
import type { | ||
BigIntLiteral, | ||
BooleanLiteral, | ||
NullLiteral, | ||
NumberLiteral, | ||
StringLiteral, | ||
UndefinedLiteral | ||
} from '@flex-development/esast' | ||
import type * as TestSubject from '../primitive' | ||
|
||
describe('unit-d:content/primitive', () => { | ||
describe('Primitive', () => { | ||
it('should equal PrimitiveMap[keyof PrimitiveMap]', () => { | ||
expectTypeOf<TestSubject.Primitive>() | ||
.toEqualTypeOf<TestSubject.PrimitiveMap[keyof TestSubject.PrimitiveMap]> | ||
}) | ||
}) | ||
|
||
describe('PrimitiveMap', () => { | ||
it('should match [bigint: BigIntLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('bigint') | ||
.toEqualTypeOf<BigIntLiteral> | ||
}) | ||
|
||
it('should match [boolean: BooleanLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('boolean') | ||
.toEqualTypeOf<BooleanLiteral> | ||
}) | ||
|
||
it('should match [null: NullLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('null') | ||
.toEqualTypeOf<NullLiteral> | ||
}) | ||
|
||
it('should match [number: NumberLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('number') | ||
.toEqualTypeOf<NumberLiteral> | ||
}) | ||
|
||
it('should match [string: StringLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('string') | ||
.toEqualTypeOf<StringLiteral> | ||
}) | ||
|
||
it('should match [undefined: UndefinedLiteral]', () => { | ||
expectTypeOf<TestSubject.PrimitiveMap>() | ||
.toHaveProperty('undefined') | ||
.toEqualTypeOf<UndefinedLiteral> | ||
}) | ||
}) | ||
}) |
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,6 @@ | ||
/** | ||
* @file Entry Point - Content Model | ||
* @module esast/content | ||
*/ | ||
|
||
export type * from './primitive' |
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,45 @@ | ||
/** | ||
* @file Content - primitive | ||
* @module esast/content/primitive | ||
*/ | ||
|
||
import type { | ||
BigIntLiteral, | ||
BooleanLiteral, | ||
NullLiteral, | ||
NumberLiteral, | ||
StringLiteral, | ||
UndefinedLiteral | ||
} from '@flex-development/esast' | ||
|
||
/** | ||
* Union of registered esast nodes that can occur where a primitive value is | ||
* expected. | ||
* | ||
* To register custom esast nodes, augment {@linkcode PrimitiveMap}. They will | ||
* be added to this union automatically. | ||
*/ | ||
type Primitive = PrimitiveMap[keyof PrimitiveMap] | ||
|
||
/** | ||
* Registry of nodes that can occur where a {@linkcode Primitive} is expected. | ||
* | ||
* This interface can be augmented to register custom node types. | ||
* | ||
* @example | ||
* declare module '@flex-development/docast' { | ||
* interface PrimitiveMap { | ||
* custom: CustomPrimitive | ||
* } | ||
* } | ||
*/ | ||
interface PrimitiveMap { | ||
bigint: BigIntLiteral | ||
boolean: BooleanLiteral | ||
null: NullLiteral | ||
number: NumberLiteral | ||
string: StringLiteral | ||
undefined: UndefinedLiteral | ||
} | ||
|
||
export type { Primitive, PrimitiveMap } |
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