diff --git a/README.md b/README.md index 98a833b6..00ef5aaf 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ It implements the [**unist**][unist] spec. - [Types](#types) - [Nodes (abstract)](#nodes-abstract) - [`Node`](#node) - - [`Position`](#position) - - [`Point`](#point) - [`Literal`](#literal) - [`Parent`](#parent) - [Nodes](#nodes) @@ -35,7 +33,7 @@ It implements the [**unist**][unist] spec. - [`Description`](#description) - [`InlineTag`](#inlinetag) - [`Root`](#root) - - [`TypeExpression`](#typeexpression) + - [`TypeMetadata`](#typemetadata) - [Mixins](#mixins) - [`Tag`](#tag) - [`TagName`](#tagname) @@ -44,6 +42,7 @@ It implements the [**unist**][unist] spec. - [`DescriptionContent`](#descriptioncontent) - [`FlowContent`](#flowcontent) - [`PhrasingContent`](#phrasingcontent) + - [`TypeExpression`](#typeexpression) - [Glossary](#glossary) - [List of utilities](#list-of-utilities) - [Contribute](#contribute) @@ -80,62 +79,20 @@ yarn add @flex-development/docast ### `Node` ```ts -interface Node extends unist.Node { - position?: Position | undefined -} +interface Node extends unist.Node {} ``` **Node** ([**unist.Node**][unist-node]) is a syntactic unit in docast syntax trees. -The `position` field represents the location of a node in a source document. The value of the `position` field implements -the [`Position`](#position) interface. The `position` field must not be present if a node is [*generated*][unist-generated]. - -#### `Position` - -```ts -interface Position { - end: Point - start: Point -} -``` - -**Position** represents the location of a node in a source [*file*][unist-file]. - -The `start` field of **Position** represents the index of the first character of the parsed source region. The `end` -field represents the index of the first character after the parsed source region, whether it exists or not. The value -of the `start` and `end` fields implement the [**Point**](#point) interface. - -If the syntactic unit represented by a node is not present in the source [*file*][unist-file] at the time of parsing, -the node is said to be [*generated*][unist-generated] and it must not have positional information. - -#### `Point` - -```ts -interface Point { - column: number // >= 1 - line: number // >= 1 - offset: number // >= 0 -} -``` - -**Point** represents one place in a source [*file*][unist-file]. - -The `line` and `column` fields are `1`-indexed integers representing a line and column in a source file. The offset -field (`0`-indexed integer) represents a character in a source file. - -The term character refers to a (UTF-16) code unit as defined by the [Web IDL specification][webidl-spec]. - ### `Literal` ```ts interface Literal extends Node { - value: string + value: bigint | boolean | number | string | null | undefined } ``` -**Literal** represents an abstract interface in docast containing a value. - -Its `value` field is a `string`. +**Literal** represents an abstract interface in docast containing the smallest possible value. ### `Parent` @@ -157,8 +114,8 @@ Its content is limited to [docast content](#content-model) and [mdast content][m ```ts interface BlockTag extends Parent, Tag { children: - | Exclude[] - | [TypeExpression, ...Exclude[]] + | Exclude[] + | [TypeMetadata, ...Exclude[]] data?: BlockTagData | undefined type: 'blockTag' } @@ -228,6 +185,7 @@ a comment, before any [**block tags**](#blocktag), and may contain [Markdown][md interface InlineTag extends Literal, Tag { data?: InlineTagData | undefined type: 'inlineTag' + value: string } ``` @@ -254,19 +212,18 @@ interface Root extends Parent { **Root** can be used as the [*root*][unist-root] of a [*tree*][unist-tree], never as a [*child*][unist-child]. It can contain [**comment**](#comment) nodes. -### `TypeExpression` +### `TypeMetadata` ```ts -interface TypeExpression extends Literal { - data?: TypeExpressionData | undefined - type: 'typeExpression' +interface TypeMetadata extends Literal { + data?: TypeMetadataData | undefined + type: 'typeMetadata' } ``` -**TypeExpression** ([**Literal**](#literal)) represents a type defintion or constraint. +**TypeMetadata** ([**Literal**](#literal)) represents an inlined type expression. -**TypeExpression** can be used in [**block tag**](#blocktag) nodes. It cannot contain any children — it is a -[*leaf*][unist-leaf]. +**TypeMetadata** can be used in [**block tag**](#blocktag) nodes. Its content model is [**type expresssion**](#typeexpression). ## Mixins @@ -301,7 +258,7 @@ falls into one or more categories of `Content`. ### `BlockTagContent` ```ts -type BlockTagContent = PhrasingContent | TypeExpression +type BlockTagContent = PhrasingContent | TypeMetadata ``` **Block** content represents [**block tag**](#blocktag) text, and its markup. @@ -339,6 +296,44 @@ type PhrasingContent = InlineTag | mdast.Code | mdast.PhrasingContent **Phrasing** content represents [**comment**](#comment) text, and its markup. +### `TypeExpression` + +```ts +type TypeExpression = + | ArrayType + | AssertionPredicate + | BigIntLiteral + | BooleanLiteral + | ConditionalType + | ConstructorType + | FunctionType + | GenericType + | Identifier + | InferType + | IntersectionType + | NonNullableType + | NullLiteral + | NullableType + | NumberLiteral + | ObjectLiteralType + | OptionalType + | ParenthesizedType + | PropertyAccessType + | StringLiteral + | Super + | TemplateLiteral + | This + | TupleType + | TypeOperation + | TypePredicate + | TypeSymbol + | UndefinedLiteral + | UnionType + | VariadicType +``` + +**TODO**: update documentation + ## Glossary See the [unist glossary][unist-glossary] for more terms. @@ -382,7 +377,6 @@ community you agree to abide by its terms. [typescript]: https://typescriptlang.org [unist-child]: https://github.com/syntax-tree/unist#child [unist-file]: https://github.com/syntax-tree/unist#file -[unist-generated]: https://github.com/syntax-tree/unist#generated [unist-glossary]: https://github.com/syntax-tree/unist#glossary [unist-leaf]: https://github.com/syntax-tree/unist#leaf [unist-node]: https://github.com/syntax-tree/unist#node @@ -392,5 +386,4 @@ community you agree to abide by its terms. [unist-tree]: https://github.com/syntax-tree/unist#tree [unist-utilities]: https://github.com/syntax-tree/unist#list-of-utilities [unist]: https://github.com/syntax-tree/unist -[webidl-spec]: https://webidl.spec.whatwg.org/ [wiki-comment]: https://en.wikipedia.org/wiki/Comment_(computer_programming) diff --git a/package.json b/package.json index 65059d43..b7868273 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "typecheck:watch": "vitest --mode=typecheck --typecheck" }, "dependencies": { - "@flex-development/tutils": "6.0.0-alpha.25", "@flex-development/unist-util-types": "1.6.1", "@types/mdast": "4.0.4", "@types/unist": "3.0.2" @@ -84,6 +83,7 @@ "@flex-development/mlly": "1.0.0-alpha.18", "@flex-development/pathe": "2.0.0", "@flex-development/tsconfig-utils": "2.0.2", + "@flex-development/tutils": "6.0.0-alpha.25", "@stylistic/eslint-plugin": "2.3.0", "@types/eslint": "8.56.10", "@types/eslint__js": "8.42.3", diff --git a/src/__tests__/docast.spec-d.ts b/src/__tests__/docast.spec-d.ts new file mode 100644 index 00000000..afdc78c0 --- /dev/null +++ b/src/__tests__/docast.spec-d.ts @@ -0,0 +1,32 @@ +/** + * @file Type Tests - docast + * @module docast/nodes/tests/unit-d/docast + */ + +import type * as TestSubject from '@flex-development/docast' +import type { Children } from '@flex-development/unist-util-types' +import type { Node } from 'unist' + +describe('unit-d:docast', () => { + describe('DocastNode', () => { + type Subject = TestSubject.DocastNode + + it('should be union of nodes', () => { + expectTypeOf>().toEqualTypeOf() + }) + }) + + describe('Extract', () => { + type Subject = Extract + + it('should override Parent["children"]', () => { + // Arrange + type Helper = T extends Children + ? Children extends T ? 0 : 1 + : unknown + + // Expect + expectTypeOf>>().toEqualTypeOf<1>() + }) + }) +}) diff --git a/src/content/__tests__/block-tag.spec-d.ts b/src/content/__tests__/block-tag.spec-d.ts index 99b0b99b..f2da812b 100644 --- a/src/content/__tests__/block-tag.spec-d.ts +++ b/src/content/__tests__/block-tag.spec-d.ts @@ -6,7 +6,7 @@ import type { NodeObject } from '#tests/types' import type { PhrasingContentMap, - TypeExpression + TypeMetadata } from '@flex-development/docast' import type mdast from 'mdast' import type * as TestSubject from '../block-tag' @@ -34,9 +34,9 @@ describe('unit-d:content/blockTag', () => { .toMatchTypeOf>() }) - it('should match NodeObject', () => { + it('should match NodeObject', () => { expectTypeOf() - .toMatchTypeOf>() + .toMatchTypeOf>() }) }) }) diff --git a/src/content/__tests__/content.spec-d.ts b/src/content/__tests__/content.spec-d.ts index 92e29595..f3a5f138 100644 --- a/src/content/__tests__/content.spec-d.ts +++ b/src/content/__tests__/content.spec-d.ts @@ -7,7 +7,8 @@ import type { BlockTagContent, DescriptionContent, FlowContent, - PhrasingContent + PhrasingContent, + TypeExpression } from '@flex-development/docast' import type TestSubject from '../content' @@ -27,4 +28,8 @@ describe('unit-d:content/content', () => { it('should allow PhrasingContent', () => { expectTypeOf().toMatchTypeOf }) + + it('should allow TypeExpression', () => { + expectTypeOf().toMatchTypeOf + }) }) diff --git a/src/content/__tests__/node.spec-d.ts b/src/content/__tests__/node.spec-d.ts index d400853e..44467de9 100644 --- a/src/content/__tests__/node.spec-d.ts +++ b/src/content/__tests__/node.spec-d.ts @@ -3,15 +3,12 @@ * @module docast/content/tests/unit-d/node */ -import type { NodeObject } from '#tests/types' +import type { InlineTag, Root } from '@flex-development/docast' import type { - BlockTag, - Comment, - Description, - InlineTag, - Root, - TypeExpression -} from '@flex-development/docast' + InclusiveDescendant, + Type +} from '@flex-development/unist-util-types' +import type mdast from 'mdast' import type * as TestSubject from '../node' describe('unit-d:content/node', () => { @@ -27,30 +24,16 @@ describe('unit-d:content/node', () => { }) describe('NodeMap', () => { - it('should match NodeObject', () => { - expectTypeOf().toMatchTypeOf>() - }) - - it('should match NodeObject', () => { - expectTypeOf().toMatchTypeOf>() - }) - - it('should match NodeObject', () => { - expectTypeOf() - .toMatchTypeOf>() - }) + type Skip = InclusiveDescendant + type Test = Exclude, Skip> | InlineTag - it('should match NodeObject', () => { - expectTypeOf().toMatchTypeOf>() - }) - - it('should match NodeObject', () => { - expectTypeOf().toMatchTypeOf>() - }) + it('should register all docast nodes', () => { + // Arrange + type Nodes = TestSubject.NodeMap[keyof TestSubject.NodeMap] - it('should match NodeObject', () => { - expectTypeOf() - .toMatchTypeOf>() + // Expect + expectTypeOf>().toEqualTypeOf() + expectTypeOf().toEqualTypeOf>() }) }) }) diff --git a/src/content/__tests__/type-expression.spec-d.ts b/src/content/__tests__/type-expression.spec-d.ts new file mode 100644 index 00000000..581f088d --- /dev/null +++ b/src/content/__tests__/type-expression.spec-d.ts @@ -0,0 +1,204 @@ +/** + * @file Type Tests - typeExpression + * @module docast/content/tests/unit-d/typeExpression + */ + +import type { NodeObject } from '#tests/types' +import type { + ArrayType, + AssertionPredicate, + BigIntLiteral, + BooleanLiteral, + ConditionalType, + ConstructorType, + FunctionType, + GenericType, + Identifier, + InferType, + IntersectionType, + NonNullableType, + NullableType, + NullLiteral, + NumberLiteral, + ObjectLiteralType, + OptionalType, + ParenthesizedType, + PropertyAccessType, + StringLiteral, + Super, + TemplateLiteral, + This, + TupleType, + TypeOperation, + TypePredicate, + TypeSymbol, + UndefinedLiteral, + UnionType, + VariadicType +} from '@flex-development/docast' +import type * as TestSubject from '../type-expression' + +describe('unit-d:content/typeExpression', () => { + describe('TypeExpression', () => { + it('should equal TypeExpressionMap[keyof TypeExpressionMap]', () => { + // Arrange + type K = keyof TestSubject.TypeExpressionMap + type Expect = TestSubject.TypeExpressionMap[K] + + // Expect + expectTypeOf().toEqualTypeOf + }) + }) + + describe('TypeExpressionMap', () => { + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + + it('should match NodeObject', () => { + expectTypeOf() + .toMatchTypeOf>() + }) + }) +}) diff --git a/src/content/block-tag.ts b/src/content/block-tag.ts index 8085b532..4b12ae04 100644 --- a/src/content/block-tag.ts +++ b/src/content/block-tag.ts @@ -5,7 +5,7 @@ import type { PhrasingContentMap, - TypeExpression + TypeMetadata } from '@flex-development/docast' import type mdast from 'mdast' @@ -22,7 +22,7 @@ type BlockTagContent = BlockTagContentMap[keyof BlockTagContentMap] * Registry of nodes that can occur where {@linkcode BlockTagContent} is * expected. * - * This interface can be augmented to register custom node types. + * This interface can be augmented to register custom nodes. * * @example * declare module '@flex-development/docast' { @@ -35,7 +35,7 @@ type BlockTagContent = BlockTagContentMap[keyof BlockTagContentMap] */ interface BlockTagContentMap extends PhrasingContentMap { code: mdast.Code - typeExpression: TypeExpression + typeMetadata: TypeMetadata } export type { BlockTagContent, BlockTagContentMap } diff --git a/src/content/content.ts b/src/content/content.ts index 693fb45e..ffe6fac1 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -7,7 +7,8 @@ import type { BlockTagContent, DescriptionContent, FlowContent, - PhrasingContent + PhrasingContent, + TypeExpression } from '@flex-development/docast' /** @@ -20,11 +21,13 @@ import type { * @see {@linkcode DescriptionContent} * @see {@linkcode FlowContent} * @see {@linkcode PhrasingContent} + * @see {@linkcode TypeExpression} */ type Content = | BlockTagContent | DescriptionContent | FlowContent | PhrasingContent + | TypeExpression export type { Content as default } diff --git a/src/content/description.ts b/src/content/description.ts index 97dc1d16..e9956056 100644 --- a/src/content/description.ts +++ b/src/content/description.ts @@ -33,7 +33,7 @@ type DescriptionContent = DescriptionContentMap[keyof DescriptionContentMap] * Registry of docast nodes that can occur where {@linkcode DescriptionContent} * is expected. * - * This interface can be augmented to register custom node types. + * This interface can be augmented to register custom nodes. * * @example * declare module '@flex-development/docast' { diff --git a/src/content/flow.ts b/src/content/flow.ts index 4284a3f6..6b1023bc 100644 --- a/src/content/flow.ts +++ b/src/content/flow.ts @@ -18,7 +18,7 @@ type FlowContent = FlowContentMap[keyof FlowContentMap] * Registry of docast nodes that can occur where {@linkcode FlowContent} is * expected. * - * This interface can be augmented to register custom node types. + * This interface can be augmented to register custom nodes. * * @example * declare module '@flex-development/docast' { diff --git a/src/content/index.ts b/src/content/index.ts index 2a486497..81b68f7d 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -9,3 +9,4 @@ export type * from './description' export type * from './flow' export type * from './node' export type * from './phrasing' +export type * from './type-expression' diff --git a/src/content/node.ts b/src/content/node.ts index 6d4950ec..5637c5ff 100644 --- a/src/content/node.ts +++ b/src/content/node.ts @@ -5,11 +5,38 @@ import type { BlockTag, + CallSignature, Comment, + ComputedPropertyName, + ComputedType, + ConstructSignature, Description, + EllipsisToken, + ExtendsPredicate, + Indexer, + IndexSignature, InlineTag, + MappedSignature, + Mapper, + MethodSignature, + MinusToken, + Modifier, + ModifierList, + Parameter, + ParameterList, + PlusToken, + PropertySignature, + ReturnType, Root, - TypeExpression + TemplateElement, + TemplatePlaceholder, + TupleElement, + TypeAnnotation, + TypeArgumentList, + TypeExpressionMap, + TypeMetadata, + TypeParameter, + TypeParameterList } from '@flex-development/docast' /** @@ -23,7 +50,7 @@ type DocastNode = NodeMap[keyof NodeMap] /** * Registry of docast nodes. * - * This interface can be augmented to register custom node types. + * This interface can be augmented to register custom nodes. * * @example * declare module '@flex-development/docast' { @@ -31,14 +58,42 @@ type DocastNode = NodeMap[keyof NodeMap] * customNode: CustomNode * } * } + * + * @extends {TypeExpressionMap} */ -interface NodeMap { +interface NodeMap extends TypeExpressionMap { blockTag: BlockTag + callSignature: CallSignature comment: Comment + computedPropertyName: ComputedPropertyName + computedType: ComputedType + constructSignature: ConstructSignature description: Description + ellipsisToken: EllipsisToken + extendsPredicate: ExtendsPredicate + indexSignature: IndexSignature + indexer: Indexer inlineTag: InlineTag + mappedSignature: MappedSignature + mapper: Mapper + methodSignature: MethodSignature + minusToken: MinusToken + modifier: Modifier + modifierList: ModifierList + parameter: Parameter + parameterList: ParameterList + plusToken: PlusToken + propertySignature: PropertySignature + returnType: ReturnType root: Root - typeExpression: TypeExpression + templateElement: TemplateElement + templatePlaceholder: TemplatePlaceholder + tupleElement: TupleElement + typeAnnotation: TypeAnnotation + typeArgumentList: TypeArgumentList + typeMetadata: TypeMetadata + typeParameter: TypeParameter + typeParameterList: TypeParameterList } export type { DocastNode, NodeMap } diff --git a/src/content/phrasing.ts b/src/content/phrasing.ts index 32d77c8d..5aa08a77 100644 --- a/src/content/phrasing.ts +++ b/src/content/phrasing.ts @@ -25,7 +25,7 @@ type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap] * Registry of docast nodes that can occur where {@linkcode PhrasingContent} is * expected. * - * This interface can be augmented to register custom node types. + * This interface can be augmented to register custom nodes. * * @example * declare module '@flex-development/docast' { diff --git a/src/content/type-expression.ts b/src/content/type-expression.ts new file mode 100644 index 00000000..22658ee0 --- /dev/null +++ b/src/content/type-expression.ts @@ -0,0 +1,94 @@ +/** + * @file Content - typeExpression + * @module docast/content/typeExpression + */ + +import type { + ArrayType, + AssertionPredicate, + BigIntLiteral, + BooleanLiteral, + ConditionalType, + ConstructorType, + FunctionType, + GenericType, + Identifier, + InferType, + IntersectionType, + NonNullableType, + NullableType, + NullLiteral, + NumberLiteral, + ObjectLiteralType, + OptionalType, + ParenthesizedType, + PropertyAccessType, + StringLiteral, + Super, + TemplateLiteral, + This, + TupleType, + TypeOperation, + TypePredicate, + TypeSymbol, + UndefinedLiteral, + UnionType, + VariadicType +} from '@flex-development/docast' + +/** + * Union of registered docast nodes that can occur where a type expression is + * expected. + * + * To register custom docast nodes, augment {@linkcode TypeExpressionMap}. They + * will be added to this union automatically. + */ +type TypeExpression = TypeExpressionMap[keyof TypeExpressionMap] + +/** + * Registry of nodes that can occur where a {@linkcode TypeExpression} is + * expected. + * + * This interface can be augmented to register custom nodes. + * + * @example + * declare module '@flex-development/docast' { + * interface TypeExpressionMap { + * customTypeExpression: CustomTypeExpression + * } + * } + */ +interface TypeExpressionMap { + arrayType: ArrayType + assertionPredicate: AssertionPredicate + bigint: BigIntLiteral + boolean: BooleanLiteral + conditionalType: ConditionalType + constructorType: ConstructorType + functionType: FunctionType + genericType: GenericType + identifier: Identifier + inferType: InferType + intersectionType: IntersectionType + nonNullableType: NonNullableType + null: NullLiteral + nullableType: NullableType + number: NumberLiteral + objectLiteralType: ObjectLiteralType + optionalType: OptionalType + parenthesizedType: ParenthesizedType + propertyAccessType: PropertyAccessType + string: StringLiteral + super: Super + templateLiteral: TemplateLiteral + this: This + tupleType: TupleType + typeOperation: TypeOperation + typePredicate: TypePredicate + typeSymbol: TypeSymbol + undefined: UndefinedLiteral + unionType: UnionType + variadicType: VariadicType +} + +export type { TypeExpression, TypeExpressionMap } diff --git a/src/interfaces/__tests__/point.spec-d.ts b/src/interfaces/__tests__/point.spec-d.ts deleted file mode 100644 index 914c73c7..00000000 --- a/src/interfaces/__tests__/point.spec-d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file Type Tests - Point - * @module docast/interfaces/tests/unit-d/Point - */ - -import type unist from 'unist' -import type TestSubject from '../point' - -describe('unit-d:interfaces/Point', () => { - it('should extend Required', () => { - expectTypeOf().toMatchTypeOf>() - }) - - it('should match [offset: number]', () => { - expectTypeOf().toHaveProperty('offset').toBeNumber() - }) -}) diff --git a/src/interfaces/__tests__/position.spec-d.ts b/src/interfaces/__tests__/position.spec-d.ts deleted file mode 100644 index 5c1ea7d1..00000000 --- a/src/interfaces/__tests__/position.spec-d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file Type Tests - Position - * @module docast/interfaces/tests/unit-d/Position - */ - -import type { Point } from '@flex-development/docast' -import type TestSubject from '../position' - -describe('unit-d:interfaces/Position', () => { - it('should match [end: Point]', () => { - expectTypeOf().toHaveProperty('end').toEqualTypeOf() - }) - - it('should match [start: Point]', () => { - expectTypeOf().toHaveProperty('start').toEqualTypeOf() - }) -}) diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index ae411ccb..23c86788 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -5,5 +5,3 @@ export type { default as CodeSegment } from './code-segment' export type { default as Data } from './data' -export type { default as Point } from './point' -export type { default as Position } from './position' diff --git a/src/interfaces/point.ts b/src/interfaces/point.ts deleted file mode 100644 index ac329833..00000000 --- a/src/interfaces/point.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file Interfaces - Point - * @module docast/interfaces/Point - */ - -import type unist from 'unist' - -/** - * One place in a source [*file*][1]. - * - * [1]: https://github.com/syntax-tree/unist#file - * - * @see {@linkcode unist.Point} - * - * @extends {Required} - */ -interface Point extends Required { - /** - * Index of character in source file (0-indexed integer). - */ - offset: number -} - -export type { Point as default } diff --git a/src/interfaces/position.ts b/src/interfaces/position.ts deleted file mode 100644 index 4188e799..00000000 --- a/src/interfaces/position.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file Interfaces - Position - * @module docast/interfaces/Position - */ - -import type { Point } from '@flex-development/docast' - -/** - * Location of a node in a source [*file*][1]. - * - * A position is a range between two points. - * - * [1]: https://github.com/syntax-tree/unist#file - */ -interface Position { - /** - * Index of first character after parsed source region. - * - * @see {@linkcode Point} - */ - end: Point - - /** - * Index of first character in parsed source region. - * - * @see {@linkcode Point} - */ - start: Point -} - -export type { Position as default } diff --git a/src/nodes/__tests__/array-type.spec-d.ts b/src/nodes/__tests__/array-type.spec-d.ts new file mode 100644 index 00000000..ecdd9167 --- /dev/null +++ b/src/nodes/__tests__/array-type.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - ArrayType + * @module docast/nodes/tests/unit-d/ArrayType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../array-type' + +describe('unit-d:nodes/ArrayType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ArrayTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ArrayTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "arrayType"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'arrayType'>() + }) + + describe('ArrayTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/assertion-predicate.spec-d.ts b/src/nodes/__tests__/assertion-predicate.spec-d.ts new file mode 100644 index 00000000..bf708246 --- /dev/null +++ b/src/nodes/__tests__/assertion-predicate.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - AssertionPredicate + * @module docast/nodes/tests/unit-d/AssertionPredicate + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../assertion-predicate' + +describe('unit-d:nodes/AssertionPredicate', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.AssertionPredicateData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: AssertionPredicateData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "assertionPredicate"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'assertionPredicate'>() + }) + + describe('AssertionPredicateData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/block-tag.spec-d.ts b/src/nodes/__tests__/block-tag.spec-d.ts index e490e332..1b92b034 100644 --- a/src/nodes/__tests__/block-tag.spec-d.ts +++ b/src/nodes/__tests__/block-tag.spec-d.ts @@ -4,11 +4,9 @@ */ import type { - BlockTagContent, Data, Parent, - Tag, - TypeExpression + Tag } from '@flex-development/docast' import type { Optional } from '@flex-development/tutils' import type * as TestSubject from '../block-tag' @@ -25,17 +23,7 @@ describe('unit-d:nodes/BlockTag', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [children: Exclude[] | [TypeExpression, ...Exclude[]]]', () => { - // Arrange - type Expect = - | Exclude[] - | [TypeExpression, ...Exclude[]] - - // Expect - expectTypeOf().toHaveProperty('children').toEqualTypeOf() - }) - - it('should match [data?: Optional]', () => { + it('should match [data?: BlockTagData | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() diff --git a/src/nodes/__tests__/comment.spec-d.ts b/src/nodes/__tests__/comment.spec-d.ts index 5c0c5148..e5064626 100644 --- a/src/nodes/__tests__/comment.spec-d.ts +++ b/src/nodes/__tests__/comment.spec-d.ts @@ -6,8 +6,6 @@ import type { CodeSegment, Data, - Description, - FlowContent, Parent } from '@flex-development/docast' import type { Nilable, Optional } from '@flex-development/tutils' @@ -21,23 +19,13 @@ describe('unit-d:nodes/Comment', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [children: Exclude[] | [Description, ...Exclude[]]]', () => { - // Arrange - type Expect = - | Exclude[] - | [summary: Description, ...Exclude[]] - - // Expect - expectTypeOf().toHaveProperty('children').toEqualTypeOf() - }) - - it('should match [code?: Nilable]', () => { + it('should match [code?: CodeSegment | null | undefined]', () => { expectTypeOf() .toHaveProperty('code') .toEqualTypeOf>() }) - it('should match [data?: Optional]', () => { + it('should match [data?: CommentData | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() diff --git a/src/nodes/__tests__/computed-property-name.spec-d.ts b/src/nodes/__tests__/computed-property-name.spec-d.ts new file mode 100644 index 00000000..f474dd0a --- /dev/null +++ b/src/nodes/__tests__/computed-property-name.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ComputedPropertyName + * @module docast/nodes/tests/unit-d/ComputedPropertyName + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../computed-property-name' + +describe('unit-d:nodes/ComputedPropertyName', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ComputedPropertyNameData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ComputedPropertyNameData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "computedPropertyName"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'computedPropertyName'>() + }) + + describe('ComputedPropertyNameData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/computed-type.spec-d.ts b/src/nodes/__tests__/computed-type.spec-d.ts new file mode 100644 index 00000000..f952589d --- /dev/null +++ b/src/nodes/__tests__/computed-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ComputedType + * @module docast/nodes/tests/unit-d/ComputedType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../computed-type' + +describe('unit-d:nodes/ComputedType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ComputedTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ComputedTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "computedType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'computedType'>() + }) + + describe('ComputedTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/conditional-type.spec-d.ts b/src/nodes/__tests__/conditional-type.spec-d.ts new file mode 100644 index 00000000..8208d453 --- /dev/null +++ b/src/nodes/__tests__/conditional-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ConditionalType + * @module docast/nodes/tests/unit-d/ConditionalType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../conditional-type' + +describe('unit-d:nodes/ConditionalType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ConditionalTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ConditionalTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "conditionalType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'conditionalType'>() + }) + + describe('ConditionalTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/constructor-type.spec-d.ts b/src/nodes/__tests__/constructor-type.spec-d.ts new file mode 100644 index 00000000..341e4472 --- /dev/null +++ b/src/nodes/__tests__/constructor-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ConstructorType + * @module docast/nodes/tests/unit-d/ConstructorType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../constructor-type' + +describe('unit-d:nodes/ConstructorType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ConstructorTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ConstructorTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "constructorType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'constructorType'>() + }) + + describe('ConstructorTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/description.spec-d.ts b/src/nodes/__tests__/description.spec-d.ts index 0003071f..bd1b09e2 100644 --- a/src/nodes/__tests__/description.spec-d.ts +++ b/src/nodes/__tests__/description.spec-d.ts @@ -5,7 +5,6 @@ import type { Data, - DescriptionContent, Parent } from '@flex-development/docast' import type { Optional } from '@flex-development/tutils' @@ -19,13 +18,7 @@ describe('unit-d:nodes/Description', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [children: DescriptionContent[]]', () => { - expectTypeOf() - .toHaveProperty('children') - .toEqualTypeOf() - }) - - it('should match [data?: Optional]', () => { + it('should match [data?: DescriptionData | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() diff --git a/src/nodes/__tests__/extends-predicate.spec-d.ts b/src/nodes/__tests__/extends-predicate.spec-d.ts new file mode 100644 index 00000000..2db3ad40 --- /dev/null +++ b/src/nodes/__tests__/extends-predicate.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ExtendsPredicate + * @module docast/nodes/tests/unit-d/ExtendsPredicate + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../extends-predicate' + +describe('unit-d:nodes/ExtendsPredicate', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ExtendsPredicateData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ExtendsPredicateData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "extendsPredicate"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'extendsPredicate'>() + }) + + describe('ExtendsPredicateData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/function-type.spec-d.ts b/src/nodes/__tests__/function-type.spec-d.ts new file mode 100644 index 00000000..6e0dde14 --- /dev/null +++ b/src/nodes/__tests__/function-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - FunctionType + * @module docast/nodes/tests/unit-d/FunctionType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../function-type' + +describe('unit-d:nodes/FunctionType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.FunctionTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: FunctionTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "functionType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'functionType'>() + }) + + describe('FunctionTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/generic-type.spec-d.ts b/src/nodes/__tests__/generic-type.spec-d.ts new file mode 100644 index 00000000..36d0d781 --- /dev/null +++ b/src/nodes/__tests__/generic-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - GenericType + * @module docast/nodes/tests/unit-d/GenericType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../generic-type' + +describe('unit-d:nodes/GenericType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.GenericTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: GenericTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "genericType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'genericType'>() + }) + + describe('GenericTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/identifier.spec-d.ts b/src/nodes/__tests__/identifier.spec-d.ts new file mode 100644 index 00000000..2da029a1 --- /dev/null +++ b/src/nodes/__tests__/identifier.spec-d.ts @@ -0,0 +1,43 @@ +/** + * @file Type Tests - Identifier + * @module docast/nodes/tests/unit-d/Identifier + */ + +import type { Data, Node } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../identifier' + +describe('unit-d:nodes/Identifier', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.IdentifierData + + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: IdentifierData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [name: string]', () => { + expectTypeOf().toHaveProperty('name').toEqualTypeOf() + }) + + it('should match [private?: boolean | null | undefined]', () => { + expectTypeOf() + .toHaveProperty('private') + .toEqualTypeOf() + }) + + it('should match [type: "identifier"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'identifier'>() + }) + + describe('IdentifierData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/indexer.spec-d.ts b/src/nodes/__tests__/indexer.spec-d.ts new file mode 100644 index 00000000..d983a939 --- /dev/null +++ b/src/nodes/__tests__/indexer.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - Indexer + * @module docast/nodes/tests/unit-d/Indexer + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../indexer' + +describe('unit-d:nodes/Indexer', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.IndexerData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: IndexerData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "indexer"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'indexer'>() + }) + + describe('IndexerData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/infer-type.spec-d.ts b/src/nodes/__tests__/infer-type.spec-d.ts new file mode 100644 index 00000000..1d7534a6 --- /dev/null +++ b/src/nodes/__tests__/infer-type.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - InferType + * @module docast/nodes/tests/unit-d/InferType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../infer-type' + +describe('unit-d:nodes/InferType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.InferTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: InferTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "inferType"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'inferType'>() + }) + + describe('InferTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/inline-tag.spec-d.ts b/src/nodes/__tests__/inline-tag.spec-d.ts index 7af50af8..7e47f867 100644 --- a/src/nodes/__tests__/inline-tag.spec-d.ts +++ b/src/nodes/__tests__/inline-tag.spec-d.ts @@ -19,7 +19,7 @@ describe('unit-d:nodes/InlineTag', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [data?: Optional]', () => { + it('should match [data?: InlineTagData | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() @@ -29,6 +29,10 @@ describe('unit-d:nodes/InlineTag', () => { expectTypeOf().toHaveProperty('type').toEqualTypeOf<'inlineTag'>() }) + it('should match [value: string]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) + describe('InlineTagData', () => { it('should extend Data', () => { expectTypeOf().toMatchTypeOf() diff --git a/src/nodes/__tests__/intersection-type.spec-d.ts b/src/nodes/__tests__/intersection-type.spec-d.ts new file mode 100644 index 00000000..252d8cac --- /dev/null +++ b/src/nodes/__tests__/intersection-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - IntersectionType + * @module docast/nodes/tests/unit-d/IntersectionType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../intersection-type' + +describe('unit-d:nodes/IntersectionType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.IntersectionTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: IntersectionTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "intersectionType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'intersectionType'>() + }) + + describe('IntersectionTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/literal-bigint.spec-d.ts b/src/nodes/__tests__/literal-bigint.spec-d.ts new file mode 100644 index 00000000..8df04792 --- /dev/null +++ b/src/nodes/__tests__/literal-bigint.spec-d.ts @@ -0,0 +1,25 @@ +/** + * @file Type Tests - BigIntLiteral + * @module docast/nodes/tests/unit-d/BigIntLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-bigint' + +describe('unit-d:nodes/BigIntLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "bigint"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'bigint'>() + }) + + it('should match [raw: string]', () => { + expectTypeOf().toHaveProperty('raw').toEqualTypeOf() + }) + + it('should match [value: bigint]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal-boolean.spec-d.ts b/src/nodes/__tests__/literal-boolean.spec-d.ts new file mode 100644 index 00000000..39fadbbc --- /dev/null +++ b/src/nodes/__tests__/literal-boolean.spec-d.ts @@ -0,0 +1,23 @@ +/** + * @file Type Tests - BooleanLiteral + * @module docast/nodes/tests/unit-d/BooleanLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-boolean' + +describe('unit-d:nodes/BooleanLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "boolean"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'boolean'>() + }) + + it('should match [value: boolean]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal-null.spec-d.ts b/src/nodes/__tests__/literal-null.spec-d.ts new file mode 100644 index 00000000..da31cc77 --- /dev/null +++ b/src/nodes/__tests__/literal-null.spec-d.ts @@ -0,0 +1,21 @@ +/** + * @file Type Tests - NullLiteral + * @module docast/nodes/tests/unit-d/NullLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-null' + +describe('unit-d:nodes/NullLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "null"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'null'>() + }) + + it('should match [value: null]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal-number.spec-d.ts b/src/nodes/__tests__/literal-number.spec-d.ts new file mode 100644 index 00000000..7979baaa --- /dev/null +++ b/src/nodes/__tests__/literal-number.spec-d.ts @@ -0,0 +1,25 @@ +/** + * @file Type Tests - NumberLiteral + * @module docast/nodes/tests/unit-d/NumberLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-number' + +describe('unit-d:nodes/NumberLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "number"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'number'>() + }) + + it('should match [raw: string]', () => { + expectTypeOf().toHaveProperty('raw').toEqualTypeOf() + }) + + it('should match [value: number]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal-string.spec-d.ts b/src/nodes/__tests__/literal-string.spec-d.ts new file mode 100644 index 00000000..6b6fd9f3 --- /dev/null +++ b/src/nodes/__tests__/literal-string.spec-d.ts @@ -0,0 +1,25 @@ +/** + * @file Type Tests - StringLiteral + * @module docast/nodes/tests/unit-d/StringLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-string' + +describe('unit-d:nodes/StringLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "string"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'string'>() + }) + + it('should match [raw: string]', () => { + expectTypeOf().toHaveProperty('raw').toEqualTypeOf() + }) + + it('should match [value: string]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal-undefined.spec-d.ts b/src/nodes/__tests__/literal-undefined.spec-d.ts new file mode 100644 index 00000000..969fdaab --- /dev/null +++ b/src/nodes/__tests__/literal-undefined.spec-d.ts @@ -0,0 +1,25 @@ +/** + * @file Type Tests - UndefinedLiteral + * @module docast/nodes/tests/unit-d/UndefinedLiteral + */ + +import type { Literal } from '@flex-development/docast' +import type TestSubject from '../literal-undefined' + +describe('unit-d:nodes/UndefinedLiteral', () => { + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "undefined"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'undefined'>() + }) + + it('should match [value: undefined]', () => { + expectTypeOf() + .toHaveProperty('value') + .toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/literal.spec-d.ts b/src/nodes/__tests__/literal.spec-d.ts index b7259692..a6a9f373 100644 --- a/src/nodes/__tests__/literal.spec-d.ts +++ b/src/nodes/__tests__/literal.spec-d.ts @@ -4,6 +4,7 @@ */ import type { Node } from '@flex-development/docast' +import type { JsonPrimitive, Optional } from '@flex-development/tutils' import type TestSubject from '../literal' describe('unit-d:nodes/Literal', () => { @@ -11,7 +12,9 @@ describe('unit-d:nodes/Literal', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [value: string]', () => { - expectTypeOf().toHaveProperty('value').toBeString() + it('should match [value: bigint | boolean | number | string | null | undefined]', () => { + expectTypeOf() + .toHaveProperty('value') + .toEqualTypeOf>() }) }) diff --git a/src/nodes/__tests__/mapper.spec-d.ts b/src/nodes/__tests__/mapper.spec-d.ts new file mode 100644 index 00000000..2b9e4cb5 --- /dev/null +++ b/src/nodes/__tests__/mapper.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - Mapper + * @module docast/nodes/tests/unit-d/Mapper + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../mapper' + +describe('unit-d:nodes/Mapper', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.MapperData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: MapperData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "mapper"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'mapper'>() + }) + + describe('MapperData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/modifier-list.spec-d.ts b/src/nodes/__tests__/modifier-list.spec-d.ts new file mode 100644 index 00000000..213e8d27 --- /dev/null +++ b/src/nodes/__tests__/modifier-list.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ModifierList + * @module docast/nodes/tests/unit-d/ModifierList + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../modifier-list' + +describe('unit-d:nodes/ModifierList', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ModifierListData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ModifierListData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "modifierList"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'modifierList'>() + }) + + describe('ModifierListData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/modifier-readonly.spec-d.ts b/src/nodes/__tests__/modifier-readonly.spec-d.ts new file mode 100644 index 00000000..eda14989 --- /dev/null +++ b/src/nodes/__tests__/modifier-readonly.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - Modifier + * @module docast/nodes/tests/unit-d/Modifier + */ + +import type { Modifier } from '@flex-development/docast' +import type TestSubject from '../modifier-readonly' + +describe('unit-d:nodes/Modifier', () => { + it('should extend Modifier', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [value: "readonly"]', () => { + expectTypeOf() + .toHaveProperty('value') + .toEqualTypeOf<'readonly'>() + }) +}) diff --git a/src/nodes/__tests__/modifier.spec-d.ts b/src/nodes/__tests__/modifier.spec-d.ts new file mode 100644 index 00000000..8c5cee60 --- /dev/null +++ b/src/nodes/__tests__/modifier.spec-d.ts @@ -0,0 +1,27 @@ +/** + * @file Type Tests - Modifier + * @module docast/nodes/tests/unit-d/Modifier + */ + +import type { Literal, ModifierKeyword } from '@flex-development/docast' +import type * as TestSubject from '../modifier' + +describe('unit-d:nodes/Modifier', () => { + type Subject = TestSubject.default + + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "modifier"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'modifier'>() + }) + + it('should match [value: ModifierKeyword]', () => { + expectTypeOf() + .toHaveProperty('value') + .toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/node.spec-d.ts b/src/nodes/__tests__/node.spec-d.ts index 312707c2..011804ad 100644 --- a/src/nodes/__tests__/node.spec-d.ts +++ b/src/nodes/__tests__/node.spec-d.ts @@ -3,7 +3,7 @@ * @module docast/nodes/tests/unit-d/Node */ -import type { Data, Position } from '@flex-development/docast' +import type { Data } from '@flex-development/docast' import type { Optional } from '@flex-development/tutils' import type unist from 'unist' import type TestSubject from '../node' @@ -13,15 +13,15 @@ describe('unit-d:nodes/Node', () => { expectTypeOf().toMatchTypeOf() }) - it('should match [data?: Optional]', () => { + it('should match [data?: Data | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() }) - it('should match [position?: Optional]', () => { + it('should match [position?: unist.Position | undefined]', () => { expectTypeOf() .toHaveProperty('position') - .toEqualTypeOf>() + .toEqualTypeOf>() }) }) diff --git a/src/nodes/__tests__/non-nullable-type.spec-d.ts b/src/nodes/__tests__/non-nullable-type.spec-d.ts new file mode 100644 index 00000000..6f646701 --- /dev/null +++ b/src/nodes/__tests__/non-nullable-type.spec-d.ts @@ -0,0 +1,39 @@ +/** + * @file Type Tests - NonNullableType + * @module docast/nodes/tests/unit-d/NonNullableType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../non-nullable-type' + +describe('unit-d:nodes/NonNullableType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.NonNullableTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: NonNullableTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [postfix: boolean]', () => { + expectTypeOf().toHaveProperty('postfix').toEqualTypeOf() + }) + + it('should match [type: "nonNullableType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'nonNullableType'>() + }) + + describe('NonNullableTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/nullable-type.spec-d.ts b/src/nodes/__tests__/nullable-type.spec-d.ts new file mode 100644 index 00000000..d84637a6 --- /dev/null +++ b/src/nodes/__tests__/nullable-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - NullableType + * @module docast/nodes/tests/unit-d/NullableType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../nullable-type' + +describe('unit-d:nodes/NullableType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.NullableTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: NullableTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "nullableType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'nullableType'>() + }) + + describe('NullableTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/object-literal-type.spec-d.ts b/src/nodes/__tests__/object-literal-type.spec-d.ts new file mode 100644 index 00000000..61c75675 --- /dev/null +++ b/src/nodes/__tests__/object-literal-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ObjectLiteralType + * @module docast/nodes/tests/unit-d/ObjectLiteralType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../object-literal-type' + +describe('unit-d:nodes/ObjectLiteralType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ObjectLiteralTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ObjectLiteralTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "objectLiteralType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'objectLiteralType'>() + }) + + describe('ObjectLiteralTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/optional-type.spec-d.ts b/src/nodes/__tests__/optional-type.spec-d.ts new file mode 100644 index 00000000..1374e479 --- /dev/null +++ b/src/nodes/__tests__/optional-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - OptionalType + * @module docast/nodes/tests/unit-d/OptionalType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../optional-type' + +describe('unit-d:nodes/OptionalType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.OptionalTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: OptionalTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "optionalType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'optionalType'>() + }) + + describe('OptionalTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/parameter-list.spec-d.ts b/src/nodes/__tests__/parameter-list.spec-d.ts new file mode 100644 index 00000000..84c858ba --- /dev/null +++ b/src/nodes/__tests__/parameter-list.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ParameterList + * @module docast/nodes/tests/unit-d/ParameterList + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../parameter-list' + +describe('unit-d:nodes/ParameterList', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ParameterListData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ParamaterListData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "parameterList"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'parameterList'>() + }) + + describe('ParameterListData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/parameter.spec-d.ts b/src/nodes/__tests__/parameter.spec-d.ts new file mode 100644 index 00000000..fe3a082e --- /dev/null +++ b/src/nodes/__tests__/parameter.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - Parameter + * @module docast/nodes/tests/unit-d/Parameter + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../parameter' + +describe('unit-d:nodes/Parameter', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ParameterData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ParameterData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "parameter"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'parameter'>() + }) + + describe('ParameterData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/parenthesized-type.spec-d.ts b/src/nodes/__tests__/parenthesized-type.spec-d.ts new file mode 100644 index 00000000..8b39fb39 --- /dev/null +++ b/src/nodes/__tests__/parenthesized-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ParenthesizedType + * @module docast/nodes/tests/unit-d/ParenthesizedType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../parenthesized-type' + +describe('unit-d:nodes/ParenthesizedType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ParenthesizedTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ParenthesizedTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "parenthesizedType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'parenthesizedType'>() + }) + + describe('ParenthesizedTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/property-access-type.spec-d.ts b/src/nodes/__tests__/property-access-type.spec-d.ts new file mode 100644 index 00000000..79ba20a1 --- /dev/null +++ b/src/nodes/__tests__/property-access-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - PropertyAccessType + * @module docast/nodes/tests/unit-d/PropertyAccessType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../property-access-type' + +describe('unit-d:nodes/PropertyAccessType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.PropertyAccessTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: PropertyAccessTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "propertyAccessType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'propertyAccessType'>() + }) + + describe('PropertyAccessTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/return-type.spec-d.ts b/src/nodes/__tests__/return-type.spec-d.ts new file mode 100644 index 00000000..48cb4f92 --- /dev/null +++ b/src/nodes/__tests__/return-type.spec-d.ts @@ -0,0 +1,39 @@ +/** + * @file Type Tests - ReturnType + * @module docast/nodes/tests/unit-d/ReturnType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../return-type' + +describe('unit-d:nodes/ReturnType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ReturnTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [arrow: boolean]', () => { + expectTypeOf().toHaveProperty('arrow').toEqualTypeOf() + }) + + it('should match [data?: ReturnTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "returnType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'returnType'>() + }) + + describe('ReturnTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/root.spec-d.ts b/src/nodes/__tests__/root.spec-d.ts index 30da309a..b06b7c9c 100644 --- a/src/nodes/__tests__/root.spec-d.ts +++ b/src/nodes/__tests__/root.spec-d.ts @@ -21,7 +21,7 @@ describe('unit-d:nodes/Root', () => { .toEqualTypeOf() }) - it('should match [data?: Optional]', () => { + it('should match [data?: RootData | undefined]', () => { expectTypeOf() .toHaveProperty('data') .toEqualTypeOf>() diff --git a/src/nodes/__tests__/signature-call.spec-d.ts b/src/nodes/__tests__/signature-call.spec-d.ts new file mode 100644 index 00000000..0eab844d --- /dev/null +++ b/src/nodes/__tests__/signature-call.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - CallSignature + * @module docast/nodes/tests/unit-d/CallSignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-call' + +describe('unit-d:nodes/CallSignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.CallSignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: CallSignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "callSignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'callSignature'>() + }) + + describe('CallSignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/signature-construct.spec-d.ts b/src/nodes/__tests__/signature-construct.spec-d.ts new file mode 100644 index 00000000..9bd0efa6 --- /dev/null +++ b/src/nodes/__tests__/signature-construct.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - ConstructSignature + * @module docast/nodes/tests/unit-d/ConstructSignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-construct' + +describe('unit-d:nodes/ConstructSignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ConstructSignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ConstructSignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "constructSignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'constructSignature'>() + }) + + describe('ConstructSignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/signature-index.spec-d.ts b/src/nodes/__tests__/signature-index.spec-d.ts new file mode 100644 index 00000000..2f204c97 --- /dev/null +++ b/src/nodes/__tests__/signature-index.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - IndexSignature + * @module docast/nodes/tests/unit-d/IndexSignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-index' + +describe('unit-d:nodes/IndexSignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.IndexSignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: IndexSignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "indexSignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'indexSignature'>() + }) + + describe('IndexSignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/signature-mapped.spec-d.ts b/src/nodes/__tests__/signature-mapped.spec-d.ts new file mode 100644 index 00000000..afc8bbb8 --- /dev/null +++ b/src/nodes/__tests__/signature-mapped.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - MappedSignature + * @module docast/nodes/tests/unit-d/MappedSignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-mapped' + +describe('unit-d:nodes/MappedSignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.MappedSignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: MappedSignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "mappedSignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'mappedSignature'>() + }) + + describe('MappedSignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/signature-method.spec-d.ts b/src/nodes/__tests__/signature-method.spec-d.ts new file mode 100644 index 00000000..42510279 --- /dev/null +++ b/src/nodes/__tests__/signature-method.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - MethodSignature + * @module docast/nodes/tests/unit-d/MethodSignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-method' + +describe('unit-d:nodes/MethodSignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.MethodSignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: MethodSignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "methodSignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'methodSignature'>() + }) + + describe('MethodSignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/signature-property.spec-d.ts b/src/nodes/__tests__/signature-property.spec-d.ts new file mode 100644 index 00000000..e333df4f --- /dev/null +++ b/src/nodes/__tests__/signature-property.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - PropertySignature + * @module docast/nodes/tests/unit-d/PropertySignature + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../signature-property' + +describe('unit-d:nodes/PropertySignature', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.PropertySignatureData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: PropertySignatureData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "propertySignature"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'propertySignature'>() + }) + + describe('PropertySignatureData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/super.spec-d.ts b/src/nodes/__tests__/super.spec-d.ts new file mode 100644 index 00000000..60070928 --- /dev/null +++ b/src/nodes/__tests__/super.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - Super + * @module docast/nodes/tests/unit-d/Super + */ + +import type { Data, Node } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../super' + +describe('unit-d:nodes/Super', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.SuperData + + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: SuperData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "super"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'super'>() + }) + + describe('SuperData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/template-element.spec-d.ts b/src/nodes/__tests__/template-element.spec-d.ts new file mode 100644 index 00000000..e21d10a0 --- /dev/null +++ b/src/nodes/__tests__/template-element.spec-d.ts @@ -0,0 +1,39 @@ +/** + * @file Type Tests - TemplateElement + * @module docast/nodes/tests/unit-d/TemplateElement + */ + +import type { Data, Literal } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../template-element' + +describe('unit-d:nodes/TemplateElement', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TemplateElementData + + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TemplateElementData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "templateElement"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'templateElement'>() + }) + + it('should match [value: string]', () => { + expectTypeOf().toHaveProperty('value').toEqualTypeOf() + }) + + describe('TemplateElementData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/template-literal.spec-d.ts b/src/nodes/__tests__/template-literal.spec-d.ts new file mode 100644 index 00000000..01dc13d1 --- /dev/null +++ b/src/nodes/__tests__/template-literal.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TemplateLiteral + * @module docast/nodes/tests/unit-d/TemplateLiteral + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../template-literal' + +describe('unit-d:nodes/TemplateLiteral', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TemplateLiteralData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TemplateLiteralData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "templateLiteral"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'templateLiteral'>() + }) + + describe('TemplateLiteralData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/template-placeholder.spec-d.ts b/src/nodes/__tests__/template-placeholder.spec-d.ts new file mode 100644 index 00000000..84adf659 --- /dev/null +++ b/src/nodes/__tests__/template-placeholder.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TemplatePlaceholder + * @module docast/nodes/tests/unit-d/TemplatePlaceholder + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../template-placeholder' + +describe('unit-d:nodes/TemplatePlaceholder', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TemplatePlaceholderData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TemplatePlaceholderData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "templatePlaceholder"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'templatePlaceholder'>() + }) + + describe('TemplatePlaceholderData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/this.spec-d.ts b/src/nodes/__tests__/this.spec-d.ts new file mode 100644 index 00000000..144630f1 --- /dev/null +++ b/src/nodes/__tests__/this.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - This + * @module docast/nodes/tests/unit-d/This + */ + +import type { Data, Node } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../this' + +describe('unit-d:nodes/This', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.ThisData + + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: ThisData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "this"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'this'>() + }) + + describe('ThisData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/token-ellipsis.spec-d.ts b/src/nodes/__tests__/token-ellipsis.spec-d.ts new file mode 100644 index 00000000..9d89009f --- /dev/null +++ b/src/nodes/__tests__/token-ellipsis.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - EllipsisToken + * @module docast/nodes/tests/unit-d/EllipsisToken + */ + +import type { Node } from '@flex-development/docast' +import type TestSubject from '../token-ellipsis' + +describe('unit-d:nodes/EllipsisToken', () => { + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "ellipsisToken"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'ellipsisToken'>() + }) +}) diff --git a/src/nodes/__tests__/token-minus.spec-d.ts b/src/nodes/__tests__/token-minus.spec-d.ts new file mode 100644 index 00000000..a3070652 --- /dev/null +++ b/src/nodes/__tests__/token-minus.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - MinusToken + * @module docast/nodes/tests/unit-d/MinusToken + */ + +import type { Node } from '@flex-development/docast' +import type TestSubject from '../token-minus' + +describe('unit-d:nodes/MinusToken', () => { + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "minusToken"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'minusToken'>() + }) +}) diff --git a/src/nodes/__tests__/token-plus.spec-d.ts b/src/nodes/__tests__/token-plus.spec-d.ts new file mode 100644 index 00000000..cbb8a80c --- /dev/null +++ b/src/nodes/__tests__/token-plus.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - PlusToken + * @module docast/nodes/tests/unit-d/PlusToken + */ + +import type { Node } from '@flex-development/docast' +import type TestSubject from '../token-plus' + +describe('unit-d:nodes/PlusToken', () => { + it('should extend Node', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "plusToken"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'plusToken'>() + }) +}) diff --git a/src/nodes/__tests__/tuple-element.spec-d.ts b/src/nodes/__tests__/tuple-element.spec-d.ts new file mode 100644 index 00000000..1240a9b5 --- /dev/null +++ b/src/nodes/__tests__/tuple-element.spec-d.ts @@ -0,0 +1,39 @@ +/** + * @file Type Tests - TupleElement + * @module docast/nodes/tests/unit-d/TupleElement + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../tuple-element' + +describe('unit-d:nodes/TupleElement', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TupleElementData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TupleElementData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [optional: boolean]', () => { + expectTypeOf().toHaveProperty('optional').toEqualTypeOf() + }) + + it('should match [type: "tupleElement"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'tupleElement'>() + }) + + describe('TupleElementData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/tuple-type.spec-d.ts b/src/nodes/__tests__/tuple-type.spec-d.ts new file mode 100644 index 00000000..64748e4d --- /dev/null +++ b/src/nodes/__tests__/tuple-type.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - TupleType + * @module docast/nodes/tests/unit-d/TupleType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../tuple-type' + +describe('unit-d:nodes/TupleType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TupleTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TupleTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "tupleType"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'tupleType'>() + }) + + describe('TupleTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-annotation.spec-d.ts b/src/nodes/__tests__/type-annotation.spec-d.ts new file mode 100644 index 00000000..7d8c0527 --- /dev/null +++ b/src/nodes/__tests__/type-annotation.spec-d.ts @@ -0,0 +1,41 @@ +/** + * @file Type Tests - TypeAnnotation + * @module docast/nodes/tests/unit-d/TypeAnnotation + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Nilable, Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-annotation' + +describe('unit-d:nodes/TypeAnnotation', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeAnnotationData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeAnnotationData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [optional?: boolean | null | undefined]', () => { + expectTypeOf() + .toHaveProperty('optional') + .toEqualTypeOf>() + }) + + it('should match [type: "typeAnnotation"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeAnnotation'>() + }) + + describe('TypeAnnotationData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-argument-list.spec-d.ts b/src/nodes/__tests__/type-argument-list.spec-d.ts new file mode 100644 index 00000000..8deced83 --- /dev/null +++ b/src/nodes/__tests__/type-argument-list.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TypeArgumentList + * @module docast/nodes/tests/unit-d/TypeArgumentList + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-argument-list' + +describe('unit-d:nodes/TypeArgumentList', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeArgumentListData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeArgumentListData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "typeArgumentList"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeArgumentList'>() + }) + + describe('TypeArgumentListData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-expression.spec-d.ts b/src/nodes/__tests__/type-expression.spec-d.ts deleted file mode 100644 index 65297385..00000000 --- a/src/nodes/__tests__/type-expression.spec-d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file Type Tests - TypeExpression - * @module docast/nodes/tests/unit-d/TypeExpression - */ - -import type { Data, Literal } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' -import type * as TestSubject from '../type-expression' - -describe('unit-d:nodes/TypeExpression', () => { - type Subject = TestSubject.default - type SubjectData = TestSubject.TypeExpressionData - - it('should extend Literal', () => { - expectTypeOf().toMatchTypeOf() - }) - - it('should match [data?: Optional]', () => { - expectTypeOf() - .toHaveProperty('data') - .toEqualTypeOf>() - }) - - it('should match [type: "typeExpression"]', () => { - expectTypeOf() - .toHaveProperty('type') - .toEqualTypeOf<'typeExpression'>() - }) - - describe('TypeExpressionData', () => { - it('should extend Data', () => { - expectTypeOf().toMatchTypeOf() - }) - }) -}) diff --git a/src/nodes/__tests__/type-metadata.spec-d.ts b/src/nodes/__tests__/type-metadata.spec-d.ts new file mode 100644 index 00000000..488cdad3 --- /dev/null +++ b/src/nodes/__tests__/type-metadata.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TypeMetadata + * @module docast/nodes/tests/unit-d/TypeMetadata + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-metadata' + +describe('unit-d:nodes/TypeMetadata', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeMetadataData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeMetadataData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "typeMetadata"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeMetadata'>() + }) + + describe('TypeMetadataData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-operation.spec-d.ts b/src/nodes/__tests__/type-operation.spec-d.ts new file mode 100644 index 00000000..56ac444f --- /dev/null +++ b/src/nodes/__tests__/type-operation.spec-d.ts @@ -0,0 +1,41 @@ +/** + * @file Type Tests - TypeOperation + * @module docast/nodes/tests/unit-d/TypeOperation + */ + +import type { Data, Parent, TypeOperator } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-operation' + +describe('unit-d:nodes/TypeOperation', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeOperationData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeOperationData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [operator: TypeOperator]', () => { + expectTypeOf() + .toHaveProperty('operator') + .toEqualTypeOf() + }) + + it('should match [type: "typeOperation"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeOperation'>() + }) + + describe('TypeOperationData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-parameter-list.spec-d.ts b/src/nodes/__tests__/type-parameter-list.spec-d.ts new file mode 100644 index 00000000..3385ad0a --- /dev/null +++ b/src/nodes/__tests__/type-parameter-list.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TypeParameterList + * @module docast/nodes/tests/unit-d/TypeParameterList + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-parameter-list' + +describe('unit-d:nodes/TypeParameterList', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeParameterListData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeParameterListData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "typeParameterList"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeParameterList'>() + }) + + describe('TypeParameterListData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-parameter.spec-d.ts b/src/nodes/__tests__/type-parameter.spec-d.ts new file mode 100644 index 00000000..ca70746b --- /dev/null +++ b/src/nodes/__tests__/type-parameter.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TypeParameter + * @module docast/nodes/tests/unit-d/TypeParameter + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-parameter' + +describe('unit-d:nodes/TypeParameter', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypeParameterData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypeParameterData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "typeParameter"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeParameter'>() + }) + + describe('TypeParameterData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-predicate.spec-d.ts b/src/nodes/__tests__/type-predicate.spec-d.ts new file mode 100644 index 00000000..247707e8 --- /dev/null +++ b/src/nodes/__tests__/type-predicate.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - TypePredicate + * @module docast/nodes/tests/unit-d/TypePredicate + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../type-predicate' + +describe('unit-d:nodes/TypePredicate', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.TypePredicateData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: TypePredicateData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "typePredicate"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typePredicate'>() + }) + + describe('TypePredicateData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/type-symbol.spec-d.ts b/src/nodes/__tests__/type-symbol.spec-d.ts new file mode 100644 index 00000000..5cf62b4f --- /dev/null +++ b/src/nodes/__tests__/type-symbol.spec-d.ts @@ -0,0 +1,27 @@ +/** + * @file Type Tests - TypeSymbol + * @module docast/nodes/tests/unit-d/TypeSymbol + */ + +import type { Literal, TypeSymbolValue } from '@flex-development/docast' +import type * as TestSubject from '../type-symbol' + +describe('unit-d:nodes/TypeSymbol', () => { + type Subject = TestSubject.default + + it('should extend Literal', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [type: "typeSymbol"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'typeSymbol'>() + }) + + it('should match [value: TypeSymbolValue]', () => { + expectTypeOf() + .toHaveProperty('value') + .toEqualTypeOf() + }) +}) diff --git a/src/nodes/__tests__/union-type.spec-d.ts b/src/nodes/__tests__/union-type.spec-d.ts new file mode 100644 index 00000000..13ed124c --- /dev/null +++ b/src/nodes/__tests__/union-type.spec-d.ts @@ -0,0 +1,33 @@ +/** + * @file Type Tests - UnionType + * @module docast/nodes/tests/unit-d/UnionType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../union-type' + +describe('unit-d:nodes/UnionType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.UnionTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: UnionTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "unionType"]', () => { + expectTypeOf().toHaveProperty('type').toEqualTypeOf<'unionType'>() + }) + + describe('UnionTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/__tests__/variadic-type.spec-d.ts b/src/nodes/__tests__/variadic-type.spec-d.ts new file mode 100644 index 00000000..4eb9849f --- /dev/null +++ b/src/nodes/__tests__/variadic-type.spec-d.ts @@ -0,0 +1,35 @@ +/** + * @file Type Tests - VariadicType + * @module docast/nodes/tests/unit-d/VariadicType + */ + +import type { Data, Parent } from '@flex-development/docast' +import type { Optional } from '@flex-development/tutils' +import type * as TestSubject from '../variadic-type' + +describe('unit-d:nodes/VariadicType', () => { + type Subject = TestSubject.default + type SubjectData = TestSubject.VariadicTypeData + + it('should extend Parent', () => { + expectTypeOf().toMatchTypeOf() + }) + + it('should match [data?: VariadicTypeData | undefined]', () => { + expectTypeOf() + .toHaveProperty('data') + .toEqualTypeOf>() + }) + + it('should match [type: "variadicType"]', () => { + expectTypeOf() + .toHaveProperty('type') + .toEqualTypeOf<'variadicType'>() + }) + + describe('VariadicTypeData', () => { + it('should extend Data', () => { + expectTypeOf().toMatchTypeOf() + }) + }) +}) diff --git a/src/nodes/array-type.ts b/src/nodes/array-type.ts new file mode 100644 index 00000000..542b29f5 --- /dev/null +++ b/src/nodes/array-type.ts @@ -0,0 +1,52 @@ +/** + * @file Nodes - ArrayType + * @module docast/nodes/ArrayType + */ + +import type { + Data, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with array types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ArrayTypeData extends Data {} + +/** + * An array type. + * + * @example + * number[] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ArrayType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ArrayTypeData} + */ + data?: ArrayTypeData | undefined + + /** + * Node type. + */ + type: 'arrayType' +} + +export type { ArrayTypeData, ArrayType as default } diff --git a/src/nodes/assertion-predicate.ts b/src/nodes/assertion-predicate.ts new file mode 100644 index 00000000..84466ff5 --- /dev/null +++ b/src/nodes/assertion-predicate.ts @@ -0,0 +1,58 @@ +/** + * @file Nodes - AssertionPredicate + * @module docast/nodes/AssertionPredicate + */ + +import type { + Data, + Identifier, + Parent, + This, + TypePredicate +} from '@flex-development/docast' + +/** + * Info associated with assertion predicates. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface AssertionPredicateData extends Data {} + +/** + * An assertion predicate. + * + * @example + * asserts condition is T + * @example + * asserts condition + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface AssertionPredicate extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode This} + * @see {@linkcode TypePredicate} + */ + children: [argument: Identifier | This | TypePredicate] + + /** + * Info from the ecosystem. + * + * @see {@linkcode AssertionPredicateData} + */ + data?: AssertionPredicateData | undefined + + /** + * Node type. + */ + type: 'assertionPredicate' +} + +export type { AssertionPredicateData, AssertionPredicate as default } diff --git a/src/nodes/block-tag.ts b/src/nodes/block-tag.ts index fefab506..e2e1f471 100644 --- a/src/nodes/block-tag.ts +++ b/src/nodes/block-tag.ts @@ -8,9 +8,8 @@ import type { Data, Parent, Tag, - TypeExpression + TypeMetadata } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' /** * Info associated with block tags. @@ -42,15 +41,15 @@ interface BlockTag extends Parent, Tag { * @see {@linkcode BlockTagContent} */ children: - | Exclude[] - | [type: TypeExpression, ...Exclude[]] + | Exclude[] + | [type: TypeMetadata, ...Exclude[]] /** * Info from the ecosystem. * * @see {@linkcode BlockTagData} */ - data?: Optional + data?: BlockTagData | undefined /** * Node type. diff --git a/src/nodes/comment.ts b/src/nodes/comment.ts index 18fa1b50..991f8988 100644 --- a/src/nodes/comment.ts +++ b/src/nodes/comment.ts @@ -10,7 +10,6 @@ import type { FlowContent, Parent } from '@flex-development/docast' -import type { Nilable, Optional } from '@flex-development/tutils' /** * Info associated with comments. @@ -48,14 +47,14 @@ interface Comment extends Parent { * * @see {@linkcode CodeSegment} */ - code?: Nilable + code?: CodeSegment | null | undefined /** * Info from the ecosystem. * * @see {@linkcode CommentData} */ - data?: Optional + data?: CommentData | undefined /** * Node type. diff --git a/src/nodes/computed-property-name.ts b/src/nodes/computed-property-name.ts new file mode 100644 index 00000000..5f526286 --- /dev/null +++ b/src/nodes/computed-property-name.ts @@ -0,0 +1,58 @@ +/** + * @file Nodes - ComputedPropertyName + * @module docast/nodes/ComputedPropertyName + */ + +import type { + Data, + Parent, + PropertyName, + TemplateLiteral +} from '@flex-development/docast' + +/** + * Info associated with computed property names. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ComputedPropertyNameData extends Data {} + +/** + * A computed property name. + * + * @example + * [key] + * @example + * ['name'] + * @example + * [`${id}`] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ComputedPropertyName extends Parent { + /** + * List of children. + * + * @see {@linkcode PropertyName} + * @see {@linkcode TemplateLiteral} + */ + children: [name: PropertyName | TemplateLiteral] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ComputedPropertyNameData} + */ + data?: ComputedPropertyNameData | undefined + + /** + * Node type. + */ + type: 'computedPropertyName' +} + +export type { ComputedPropertyNameData, ComputedPropertyName as default } diff --git a/src/nodes/computed-type.ts b/src/nodes/computed-type.ts new file mode 100644 index 00000000..fd6a85d4 --- /dev/null +++ b/src/nodes/computed-type.ts @@ -0,0 +1,50 @@ +/** + * @file Nodes - ComputedType + * @module docast/nodes/ComputedType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with computed types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ComputedTypeData extends Data {} + +/** + * A type expression wrapped in brackets. + * + * @example + * [K] + * @example + * ['key'] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ComputedType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ComputedTypeData} + */ + data?: ComputedTypeData | undefined + + /** + * Node type. + */ + type: 'computedType' +} + +export type { ComputedTypeData, ComputedType as default } diff --git a/src/nodes/conditional-type.ts b/src/nodes/conditional-type.ts new file mode 100644 index 00000000..5d107089 --- /dev/null +++ b/src/nodes/conditional-type.ts @@ -0,0 +1,59 @@ +/** + * @file Nodes - ConditionalType + * @module docast/nodes/ConditionalType + */ + +import type { + Data, + ExtendsPredicate, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with conditional types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ConditionalTypeData extends Data {} + +/** + * A conditional type. + * + * @example + * T extends number ? true : false + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ConditionalType extends Parent { + /** + * List of children. + * + * @see {@linkcode ExtendsPredicate} + * @see {@linkcode TypeExpression} + */ + children: [ + type: TypeExpression, + extend: ExtendsPredicate, + alternate: TypeExpression, + consequent: TypeExpression + ] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ConditionalTypeData} + */ + data?: ConditionalTypeData | undefined + + /** + * Node type. + */ + type: 'conditionalType' +} + +export type { ConditionalTypeData, ConditionalType as default } diff --git a/src/nodes/constructor-type.ts b/src/nodes/constructor-type.ts new file mode 100644 index 00000000..e623c3f2 --- /dev/null +++ b/src/nodes/constructor-type.ts @@ -0,0 +1,50 @@ +/** + * @file Nodes - ConstructorType + * @module docast/nodes/ConstructorType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with constructor types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ConstructorTypeData extends Data {} + +/** + * A constructor type. + * + * @example + * new () => Base + * @example + * new (options: Options, ...plugins: Plugin[]) => Base + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ConstructorType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [construct: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ConstructorTypeData} + */ + data?: ConstructorTypeData | undefined + + /** + * Node type. + */ + type: 'constructorType' +} + +export type { ConstructorTypeData, ConstructorType as default } diff --git a/src/nodes/description.ts b/src/nodes/description.ts index 3e7c25fb..9ddc68b4 100644 --- a/src/nodes/description.ts +++ b/src/nodes/description.ts @@ -8,7 +8,6 @@ import type { DescriptionContent, Parent } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' /** * Info associated with comment descriptions. @@ -39,7 +38,7 @@ interface Description extends Parent { * * @see {@linkcode DescriptionData} */ - data?: Optional + data?: DescriptionData | undefined /** * Node type. @@ -47,4 +46,4 @@ interface Description extends Parent { type: 'description' } -export type { DescriptionData, Description as default } +export type { Description as default, DescriptionData } diff --git a/src/nodes/extends-predicate.ts b/src/nodes/extends-predicate.ts new file mode 100644 index 00000000..03ba6fb6 --- /dev/null +++ b/src/nodes/extends-predicate.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - ExtendsPredicate + * @module docast/nodes/ExtendsPredicate + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with `extends` predicates. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ExtendsPredicateData extends Data {} + +/** + * An `extends` predicate. + * + * @example + * extends number + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ExtendsPredicate extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ExtendsPredicateData} + */ + data?: ExtendsPredicateData | undefined + + /** + * Node type. + */ + type: 'extendsPredicate' +} + +export type { ExtendsPredicate as default, ExtendsPredicateData } diff --git a/src/nodes/function-type.ts b/src/nodes/function-type.ts new file mode 100644 index 00000000..cdc1d07a --- /dev/null +++ b/src/nodes/function-type.ts @@ -0,0 +1,68 @@ +/** + * @file Nodes - FunctionType + * @module docast/nodes/FunctionType + */ + +import type { + Data, + ParameterList, + Parent, + ReturnType, + TypeParameterList +} from '@flex-development/docast' + +/** + * Info associated with function types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface FunctionTypeData extends Data {} + +/** + * A function type. + * + * @example + * (list: number[]) => number + * @example + * function(number[]): number + * @example + * function(number[]) + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface FunctionType extends Parent { + /** + * Boolean indicating arrow function syntax. + */ + arrow: boolean + + /** + * List of children. + * + * @see {@linkcode ParameterList} + * @see {@linkcode ReturnType} + * @see {@linkcode TypeParameterList} + */ + children: + | [params: ParameterList, ret: ReturnType] + | [params: ParameterList] + | [typeParams: TypeParameterList, params: ParameterList, ret: ReturnType] + + /** + * Info from the ecosystem. + * + * @see {@linkcode FunctionTypeData} + */ + data?: FunctionTypeData | undefined + + /** + * Node type. + */ + type: 'functionType' +} + +export type { FunctionType as default, FunctionTypeData } diff --git a/src/nodes/generic-type.ts b/src/nodes/generic-type.ts new file mode 100644 index 00000000..5c5a9052 --- /dev/null +++ b/src/nodes/generic-type.ts @@ -0,0 +1,54 @@ +/** + * @file Nodes - GenericType + * @module docast/nodes/GenericType + */ + +import type { + Data, + Identifier, + Parent, + TypeArgumentList +} from '@flex-development/docast' + +/** + * Info associated with generic types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface GenericTypeData extends Data {} + +/** + * A generic type. + * + * @example + * Token + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface GenericType extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode TypeArgumentList} + */ + children: [generic: Identifier, arguments: TypeArgumentList] + + /** + * Info from the ecosystem. + * + * @see {@linkcode GenericTypeData} + */ + data?: GenericTypeData | undefined + + /** + * Node type. + */ + type: 'genericType' +} + +export type { GenericType as default, GenericTypeData } diff --git a/src/nodes/identifier.ts b/src/nodes/identifier.ts new file mode 100644 index 00000000..62d80794 --- /dev/null +++ b/src/nodes/identifier.ts @@ -0,0 +1,51 @@ +/** + * @file Nodes - Identifier + * @module docast/nodes/Identifier + */ + +import type { Data, Node } from '@flex-development/docast' + +/** + * Info associated with identifiers. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface IdentifierData extends Data {} + +/** + * An identifier. + * + * @example + * foo + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface Identifier extends Node { + /** + * Info from the ecosystem. + * + * @see {@linkcode IdentifierData} + */ + data?: IdentifierData | undefined + + /** + * Identifier name. + */ + name: string + + /** + * Boolean indicating private identifier. + */ + private?: boolean | null | undefined + + /** + * Node type. + */ + type: 'identifier' +} + +export type { Identifier as default, IdentifierData } diff --git a/src/nodes/index.ts b/src/nodes/index.ts index 01a72595..c95e6780 100644 --- a/src/nodes/index.ts +++ b/src/nodes/index.ts @@ -4,15 +4,150 @@ * @see https://github.com/syntax-tree/unist#nodes */ +export type { default as ArrayType, ArrayTypeData } from './array-type' +export type { + default as AssertionPredicate, + AssertionPredicateData +} from './assertion-predicate' export type { default as BlockTag, BlockTagData } from './block-tag' export type { default as Comment, CommentData } from './comment' +export type { + default as ComputedPropertyName, + ComputedPropertyNameData +} from './computed-property-name' +export type { default as ComputedType, ComputedTypeData } from './computed-type' +export type { + default as ConditionalType, + ConditionalTypeData +} from './conditional-type' +export type { + default as ConstructorType, + ConstructorTypeData +} from './constructor-type' export type { default as Description, DescriptionData } from './description' +export type { + default as ExtendsPredicate, + ExtendsPredicateData +} from './extends-predicate' +export type { default as FunctionType, FunctionTypeData } from './function-type' +export type { default as GenericType, GenericTypeData } from './generic-type' +export type { default as Identifier, IdentifierData } from './identifier' +export type { default as Indexer, IndexerData } from './indexer' +export type { default as InferType, InferTypeData } from './infer-type' export type { default as InlineTag, InlineTagData } from './inline-tag' +export type { + default as IntersectionType, + IntersectionTypeData +} from './intersection-type' 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 StringLiteral } from './literal-string' +export type { default as UndefinedLiteral } from './literal-undefined' +export type { default as Mapper, MapperData } from './mapper' +export type { default as Modifier } from './modifier' +export type { default as ModifierList, ModifierListData } from './modifier-list' +export type { default as ReadonlyModifier } from './modifier-readonly' export type { default as Node } from './node' +export type { + default as NonNullableType, + NonNullableTypeData +} from './non-nullable-type' +export type { + default as NullableType, + NullableTypeData +} from './nullable-type' +export type { + default as ObjectLiteralType, + ObjectLiteralTypeData +} from './object-literal-type' +export type { default as OptionalType, OptionalTypeData } from './optional-type' +export type { default as Parameter, ParameterData } from './parameter' +export type { + default as ParameterList, + ParameterListData +} from './parameter-list' export type { default as Parent } from './parent' +export type { + default as ParenthesizedType, + ParenthesizedTypeData +} from './parenthesized-type' +export type { + default as PropertyAccessType, + PropertyAccessTypeData +} from './property-access-type' +export type { default as ReturnType, ReturnTypeData } from './return-type' export type { default as Root, RootData } from './root' export type { - default as TypeExpression, - TypeExpressionData -} from './type-expression' + default as CallSignature, + CallSignatureData +} from './signature-call' +export type { + default as ConstructSignature, + ConstructSignatureData +} from './signature-construct' +export type { + default as IndexSignature, + IndexSignatureData +} from './signature-index' +export type { + default as MappedSignature, + MappedSignatureData +} from './signature-mapped' +export type { + default as MethodSignature, + MethodSignatureData +} from './signature-method' +export type { + default as PropertySignature, + PropertySignatureData +} from './signature-property' +export type { default as Super, SuperData } from './super' +export type { + default as TemplateElement, + TemplateElementData +} from './template-element' +export type { + default as TemplateLiteral, + TemplateLiteralData +} from './template-literal' +export type { + default as TemplatePlaceholder, + TemplatePlaceholderData +} from './template-placeholder' +export type { default as This, ThisData } from './this' +export type { default as EllipsisToken } from './token-ellipsis' +export type { default as MinusToken } from './token-minus' +export type { default as PlusToken } from './token-plus' +export type { default as TupleElement, TupleElementData } from './tuple-element' +export type { default as TupleType, TupleTypeData } from './tuple-type' +export type { + default as TypeAnnotation, + TypeAnnotationData +} from './type-annotation' +export type { + default as TypeArgumentList, + TypeArgumentListData +} from './type-argument-list' +export type { default as TypeMetadata, TypeMetadataData } from './type-metadata' +export type { + default as TypeOperation, + TypeOperationData +} from './type-operation' +export type { + default as TypeParameter, + TypeParameterData +} from './type-parameter' +export type { + default as TypeParameterList, + TypeParameterListData +} from './type-parameter-list' +export type { + default as TypePredicate, + TypePredicateData +} from './type-predicate' +export type { default as TypeSymbol } from './type-symbol' +export type { default as UnionType, UnionTypeData } from './union-type' +export type { default as VariadicType, VariadicTypeData } from './variadic-type' diff --git a/src/nodes/indexer.ts b/src/nodes/indexer.ts new file mode 100644 index 00000000..def8b722 --- /dev/null +++ b/src/nodes/indexer.ts @@ -0,0 +1,54 @@ +/** + * @file Nodes - Indexer + * @module docast/nodes/Indexer + */ + +import type { + Data, + Identifier, + Parent, + ReturnType +} from '@flex-development/docast' + +/** + * Info associated with index signature operations. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface IndexerData extends Data {} + +/** + * An index signature operation. + * + * @example + * [index: number] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface Indexer extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode ReturnType} + */ + children: [name: Identifier, type: ReturnType] + + /** + * Info from the ecosystem. + * + * @see {@linkcode IndexerData} + */ + data?: IndexerData | undefined + + /** + * Node type. + */ + type: 'indexer' +} + +export type { Indexer as default, IndexerData } diff --git a/src/nodes/infer-type.ts b/src/nodes/infer-type.ts new file mode 100644 index 00000000..3349b183 --- /dev/null +++ b/src/nodes/infer-type.ts @@ -0,0 +1,58 @@ +/** + * @file Nodes - InferType + * @module docast/nodes/InferType + */ + +import type { + Data, + ExtendsPredicate, + Identifier, + Parent +} from '@flex-development/docast' + +/** + * Info associated with `infer` types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface InferTypeData extends Data {} + +/** + * An `infer` type. + * + * @example + * infer N extends Node + * @example + * infer N + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface InferType extends Parent { + /** + * List of children. + * + * @see {@linkcode ExtendsPredicate} + * @see {@linkcode Identifier} + */ + children: + | [identifier: Identifier, extend: ExtendsPredicate] + | [identifier: Identifier] + + /** + * Info from the ecosystem. + * + * @see {@linkcode InferTypeData} + */ + data?: InferTypeData | undefined + + /** + * Node type. + */ + type: 'inferType' +} + +export type { InferType as default, InferTypeData } diff --git a/src/nodes/inline-tag.ts b/src/nodes/inline-tag.ts index fca08f0b..96209bb3 100644 --- a/src/nodes/inline-tag.ts +++ b/src/nodes/inline-tag.ts @@ -4,7 +4,6 @@ */ import type { Data, Literal, Tag } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' /** * Info associated with inline tags. @@ -33,12 +32,17 @@ interface InlineTag extends Literal, Tag { * * @see {@linkcode InlineTagData} */ - data?: Optional + data?: InlineTagData | undefined /** * Node type. */ type: 'inlineTag' + + /** + * Plain-text value. + */ + value: string } -export type { InlineTagData, InlineTag as default } +export type { InlineTag as default, InlineTagData } diff --git a/src/nodes/intersection-type.ts b/src/nodes/intersection-type.ts new file mode 100644 index 00000000..02568877 --- /dev/null +++ b/src/nodes/intersection-type.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - IntersectionType + * @module docast/nodes/IntersectionType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with intersection types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface IntersectionTypeData extends Data {} + +/** + * An intersection type. + * + * @example + * Payload & { id: string } + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface IntersectionType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [left: TypeExpression, right: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode IntersectionTypeData} + */ + data?: IntersectionTypeData | undefined + + /** + * Node type. + */ + type: 'intersectionType' +} + +export type { IntersectionType as default, IntersectionTypeData } diff --git a/src/nodes/literal-bigint.ts b/src/nodes/literal-bigint.ts new file mode 100644 index 00000000..8e7ee06c --- /dev/null +++ b/src/nodes/literal-bigint.ts @@ -0,0 +1,37 @@ +/** + * @file Nodes - BigIntLiteral + * @module docast/nodes/BigIntLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * A `bigint` literal. + * + * @example + * 0xdn + * @example + * 13n + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface BigIntLiteral extends Literal { + /** + * Node type. + */ + type: 'bigint' + + /** + * Raw value. + */ + raw: string + + /** + * Plain value. + */ + value: bigint +} + +export type { BigIntLiteral as default } diff --git a/src/nodes/literal-boolean.ts b/src/nodes/literal-boolean.ts new file mode 100644 index 00000000..c77e46aa --- /dev/null +++ b/src/nodes/literal-boolean.ts @@ -0,0 +1,32 @@ +/** + * @file Nodes - BooleanLiteral + * @module docast/nodes/BooleanLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * A boolean literal. + * + * @example + * false + * @example + * true + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface BooleanLiteral extends Literal { + /** + * Node type. + */ + type: 'boolean' + + /** + * Plain value. + */ + value: boolean +} + +export type { BooleanLiteral as default } diff --git a/src/nodes/literal-null.ts b/src/nodes/literal-null.ts new file mode 100644 index 00000000..ecaeefda --- /dev/null +++ b/src/nodes/literal-null.ts @@ -0,0 +1,27 @@ +/** + * @file Nodes - NullLiteral + * @module docast/nodes/NullLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * The value `null`. + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface NullLiteral extends Literal { + /** + * Node type. + */ + type: 'null' + + /** + * Plain value. + */ + value: null +} + +export type { NullLiteral as default } diff --git a/src/nodes/literal-number.ts b/src/nodes/literal-number.ts new file mode 100644 index 00000000..e8b98b68 --- /dev/null +++ b/src/nodes/literal-number.ts @@ -0,0 +1,43 @@ +/** + * @file Nodes - NumberLiteral + * @module docast/nodes/NumberLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * An integer, float, or exponential number. + * + * @example + * 0xd + * @example + * 13 + * @example + * 13.0 + * @example + * 1_3 + * @example + * 13e1 + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface NumberLiteral extends Literal { + /** + * Node type. + */ + type: 'number' + + /** + * Raw value. + */ + raw: string + + /** + * Plain value. + */ + value: number +} + +export type { NumberLiteral as default } diff --git a/src/nodes/literal-string.ts b/src/nodes/literal-string.ts new file mode 100644 index 00000000..f9b1b63a --- /dev/null +++ b/src/nodes/literal-string.ts @@ -0,0 +1,37 @@ +/** + * @file Nodes - StringLiteral + * @module docast/nodes/StringLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * A string literal. + * + * @example + * 'hello' + * @example + * "world" + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface StringLiteral extends Literal { + /** + * Node type. + */ + type: 'string' + + /** + * Raw value. + */ + raw: string + + /** + * Plain value. + */ + value: string +} + +export type { StringLiteral as default } diff --git a/src/nodes/literal-undefined.ts b/src/nodes/literal-undefined.ts new file mode 100644 index 00000000..df9e0260 --- /dev/null +++ b/src/nodes/literal-undefined.ts @@ -0,0 +1,27 @@ +/** + * @file Nodes - UndefinedLiteral + * @module docast/nodes/UndefinedLiteral + */ + +import type { Literal } from '@flex-development/docast' + +/** + * The value `undefined`. + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface UndefinedLiteral extends Literal { + /** + * Node type. + */ + type: 'undefined' + + /** + * Plain value. + */ + value: undefined +} + +export type { UndefinedLiteral as default } diff --git a/src/nodes/literal.ts b/src/nodes/literal.ts index 02d7c0c7..5a55feeb 100644 --- a/src/nodes/literal.ts +++ b/src/nodes/literal.ts @@ -14,9 +14,9 @@ import type { Node } from '@flex-development/docast' */ interface Literal extends Node { /** - * Plain-text value. + * Plain value. */ - value: string + value: bigint | boolean | number | string | null | undefined } export type { Literal as default } diff --git a/src/nodes/mapper.ts b/src/nodes/mapper.ts new file mode 100644 index 00000000..bdbeabad --- /dev/null +++ b/src/nodes/mapper.ts @@ -0,0 +1,54 @@ +/** + * @file Nodes - Mapper + * @module docast/nodes/Mapper + */ + +import type { + Data, + Identifier, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with mapped signature keys. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface MapperData extends Data {} + +/** + * A mapped signature operation. + * + * @example + * [K in keyof T] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface Mapper extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode TypeExpression} + */ + children: [name: Identifier, type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode MapperData} + */ + data?: MapperData | undefined + + /** + * Node type. + */ + type: 'mapper' +} + +export type { Mapper as default, MapperData } diff --git a/src/nodes/modifier-list.ts b/src/nodes/modifier-list.ts new file mode 100644 index 00000000..bc4f3ece --- /dev/null +++ b/src/nodes/modifier-list.ts @@ -0,0 +1,52 @@ +/** + * @file Nodes - ModifierList + * @module docast/nodes/ModifierList + */ + +import type { Data, Modifier, Parent } from '@flex-development/docast' + +/** + * Info associated with modifier lists. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ModifierListData extends Data {} + +/** + * A modifier list. + * + * @example + * in out + * @example + * get + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ModifierList extends Parent { + /** + * List of children. + * + * @see {@linkcode Modifier} + */ + children: + | [first: Modifier, ...middle: Modifier[], last: Modifier] + | [first: Modifier] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ModifierListData} + */ + data?: ModifierListData | undefined + + /** + * Node type. + */ + type: 'modifierList' +} + +export type { ModifierList as default, ModifierListData } diff --git a/src/nodes/modifier-readonly.ts b/src/nodes/modifier-readonly.ts new file mode 100644 index 00000000..57e1daeb --- /dev/null +++ b/src/nodes/modifier-readonly.ts @@ -0,0 +1,22 @@ +/** + * @file Nodes - ReadonlyModifier + * @module docast/nodes/ReadonlyModifier + */ + +import type { Modifier } from '@flex-development/docast' + +/** + * The `readonly` modifier. + * + * @see {@linkcode Modifier} + * + * @extends {Modifier} + */ +interface ReadonlyModifier extends Modifier { + /** + * The modifier keyword. + */ + value: 'readonly' +} + +export type { ReadonlyModifier as default } diff --git a/src/nodes/modifier.ts b/src/nodes/modifier.ts new file mode 100644 index 00000000..5973693f --- /dev/null +++ b/src/nodes/modifier.ts @@ -0,0 +1,29 @@ +/** + * @file Nodes - Modifier + * @module docast/nodes/Modifier + */ + +import type { Literal, ModifierKeyword } from '@flex-development/docast' + +/** + * A modifier keyword. + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface Modifier extends Literal { + /** + * Node type. + */ + type: 'modifier' + + /** + * The modifier keyword. + * + * @see {@linkcode ModifierKeyword} + */ + value: ModifierKeyword +} + +export type { Modifier as default } diff --git a/src/nodes/node.ts b/src/nodes/node.ts index 236f8f0f..5a9b5953 100644 --- a/src/nodes/node.ts +++ b/src/nodes/node.ts @@ -3,8 +3,7 @@ * @module docast/nodes/Node */ -import type { Data, Position } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' +import type { Data } from '@flex-development/docast' import type unist from 'unist' /** @@ -20,18 +19,18 @@ interface Node extends unist.Node { * * @see {@linkcode Data} */ - data?: Optional + data?: Data | undefined /** * Location of node in source document. * - * **Note**: Should not be defined if node is [*generated*][1]. + * > 👉 Nodes that are [*generated*][generated] must not have a position. * - * [1]: https://github.com/syntax-tree/unist#generated + * [generated]: https://github.com/syntax-tree/unist#generated * - * @see {@linkcode Position} + * @see {@linkcode unist.Position} */ - position?: Optional + position?: unist.Position | undefined } export type { Node as default } diff --git a/src/nodes/non-nullable-type.ts b/src/nodes/non-nullable-type.ts new file mode 100644 index 00000000..4a8256d3 --- /dev/null +++ b/src/nodes/non-nullable-type.ts @@ -0,0 +1,57 @@ +/** + * @file Nodes - NonNullableType + * @module docast/nodes/NonNullableType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with non-nullable types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface NonNullableTypeData extends Data {} + +/** + * A non-nullable type. + * + * @example + * !number + * @example + * number! + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface NonNullableType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [argument: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode NonNullableTypeData} + */ + data?: NonNullableTypeData | undefined + + /** + * Boolean indicating if operator should follow the argument. + * + * If `false`, the operator should precede the argument. + */ + postfix: boolean + + /** + * Node type. + */ + type: 'nonNullableType' +} + +export type { NonNullableType as default, NonNullableTypeData } diff --git a/src/nodes/nullable-type.ts b/src/nodes/nullable-type.ts new file mode 100644 index 00000000..10439d1a --- /dev/null +++ b/src/nodes/nullable-type.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - NullableType + * @module docast/nodes/NullableType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with nullable types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface NullableTypeData extends Data {} + +/** + * A nullable type. + * + * @example + * ?number + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface NullableType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode NullableTypeData} + */ + data?: NullableTypeData | undefined + + /** + * Node type. + */ + type: 'nullableType' +} + +export type { NullableType as default, NullableTypeData } diff --git a/src/nodes/object-literal-type.ts b/src/nodes/object-literal-type.ts new file mode 100644 index 00000000..6ebfe787 --- /dev/null +++ b/src/nodes/object-literal-type.ts @@ -0,0 +1,69 @@ +/** + * @file Nodes - ObjectLiteralType + * @module docast/nodes/ObjectLiteralType + */ + +import type { + CallSignature, + ConstructSignature, + Data, + IndexSignature, + MappedSignature, + MethodSignature, + Parent, + PropertySignature +} from '@flex-development/docast' + +/** + * Info associated with object literal types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ObjectLiteralTypeData extends Data {} + +/** + * An object literal type. + * + * @example + * { x: number } + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ObjectLiteralType extends Parent { + /** + * List of children. + * + * @see {@linkcode CallSignature} + * @see {@linkcode ConstructSignature} + * @see {@linkcode IndexSignature} + * @see {@linkcode MappedSignature} + * @see {@linkcode MethodSignature} + * @see {@linkcode PropertySignature} + */ + children: ( + | CallSignature + | ConstructSignature + | IndexSignature + | MappedSignature + | MethodSignature + | PropertySignature + )[] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ObjectLiteralTypeData} + */ + data?: ObjectLiteralTypeData | undefined + + /** + * Node type. + */ + type: 'objectLiteralType' +} + +export type { ObjectLiteralType as default, ObjectLiteralTypeData } diff --git a/src/nodes/optional-type.ts b/src/nodes/optional-type.ts new file mode 100644 index 00000000..e82e9259 --- /dev/null +++ b/src/nodes/optional-type.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - OptionalType + * @module docast/nodes/OptionalType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with optional types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface OptionalTypeData extends Data {} + +/** + * An optional type. + * + * @example + * number? + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface OptionalType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [argument: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode OptionalTypeData} + */ + data?: OptionalTypeData | undefined + + /** + * Node type. + */ + type: 'optionalType' +} + +export type { OptionalType as default, OptionalTypeData } diff --git a/src/nodes/parameter-list.ts b/src/nodes/parameter-list.ts new file mode 100644 index 00000000..42d20349 --- /dev/null +++ b/src/nodes/parameter-list.ts @@ -0,0 +1,50 @@ +/** + * @file Nodes - ParameterList + * @module docast/nodes/ParameterList + */ + +import type { Data, Parameter, Parent } from '@flex-development/docast' + +/** + * Info associated with parameter lists. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ParameterListData extends Data {} + +/** + * A parameter list. + * + * @example + * (acc: number[], num: number) + * @example + * (a, b) + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ParameterList extends Parent { + /** + * List of children. + * + * @see {@linkcode Parameter} + */ + children: Parameter[] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ParameterListData} + */ + data?: ParameterListData | undefined + + /** + * Node type. + */ + type: 'parameterList' +} + +export type { ParameterList as default, ParameterListData } diff --git a/src/nodes/parameter.ts b/src/nodes/parameter.ts new file mode 100644 index 00000000..78b745a7 --- /dev/null +++ b/src/nodes/parameter.ts @@ -0,0 +1,64 @@ +/** + * @file Nodes - Parameter + * @module docast/nodes/Parameter + */ + +import type { + Data, + Identifier, + Parent, + Super, + This, + TypeAnnotation, + TypeSymbol +} from '@flex-development/docast' + +/** + * Info associated with parameters. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ParameterData extends Data {} + +/** + * A function parameter. + * + * @example + * this: void + * @example + * str + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface Parameter extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode Super} + * @see {@linkcode This} + * @see {@linkcode TypeAnnotation} + * @see {@linkcode TypeSymbol} + */ + children: + | [parameter: Identifier | Super | This, type: TypeAnnotation] + | [parameter: Identifier | Super | This | TypeSymbol] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ParameterData} + */ + data?: ParameterData | undefined + + /** + * Node type. + */ + type: 'parameter' +} + +export type { Parameter as default, ParameterData } diff --git a/src/nodes/parenthesized-type.ts b/src/nodes/parenthesized-type.ts new file mode 100644 index 00000000..79e00835 --- /dev/null +++ b/src/nodes/parenthesized-type.ts @@ -0,0 +1,45 @@ +/** + * @file Nodes - ParenthesizedType + * @module docast/nodes/ParenthesizedType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with parenthesized types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ParenthesizedTypeData extends Data {} + +/** + * A type expression wrapped in parentheses. + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ParenthesizedType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ParenthesizedTypeData} + */ + data?: ParenthesizedTypeData | undefined + + /** + * Node type. + */ + type: 'parenthesizedType' +} + +export type { ParenthesizedType as default, ParenthesizedTypeData } diff --git a/src/nodes/property-access-type.ts b/src/nodes/property-access-type.ts new file mode 100644 index 00000000..31d85adc --- /dev/null +++ b/src/nodes/property-access-type.ts @@ -0,0 +1,51 @@ +/** + * @file Nodes - PropertyAccessType + * @module docast/nodes/PropertyAccessType + */ + +import type { + ComputedType, + Data, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with property access types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface PropertyAccessTypeData extends Data {} + +/** + * A property access type (`a.b`, `arr[0]`). + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface PropertyAccessType extends Parent { + /** + * List of children. + * + * @see {@linkcode ComputedType} + * @see {@linkcode TypeExpression} + */ + children: [object: TypeExpression, property: ComputedType | TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode PropertyAccessTypeData} + */ + data?: PropertyAccessTypeData | undefined + + /** + * Node type. + */ + type: 'propertyAccessType' +} + +export type { PropertyAccessType as default, PropertyAccessTypeData } diff --git a/src/nodes/return-type.ts b/src/nodes/return-type.ts new file mode 100644 index 00000000..c207dbe8 --- /dev/null +++ b/src/nodes/return-type.ts @@ -0,0 +1,61 @@ +/** + * @file Nodes - ReturnType + * @module docast/nodes/ReturnType + */ + +import type { + Data, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with return types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ReturnTypeData extends Data {} + +/** + * A return type. + * + * @example + * => number + * @example + * : number + * @example + * function(number[]) + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ReturnType extends Parent { + /** + * Boolean indicating arrow syntax. + */ + arrow: boolean + + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ReturnTypeData} + */ + data?: ReturnTypeData | undefined + + /** + * Node type. + */ + type: 'returnType' +} + +export type { ReturnType as default, ReturnTypeData } diff --git a/src/nodes/root.ts b/src/nodes/root.ts index 86ec33a9..cf8934ac 100644 --- a/src/nodes/root.ts +++ b/src/nodes/root.ts @@ -4,7 +4,6 @@ */ import type { Comment, Data, Parent } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' /** * Info associated with documents. @@ -37,7 +36,7 @@ interface Root extends Parent { * * @see {@linkcode RootData} */ - data?: Optional + data?: RootData | undefined /** * Node type. @@ -45,4 +44,4 @@ interface Root extends Parent { type: 'root' } -export type { RootData, Root as default } +export type { Root as default, RootData } diff --git a/src/nodes/signature-call.ts b/src/nodes/signature-call.ts new file mode 100644 index 00000000..88e656ac --- /dev/null +++ b/src/nodes/signature-call.ts @@ -0,0 +1,64 @@ +/** + * @file Nodes - CallSignature + * @module docast/nodes/CallSignature + */ + +import type { + Data, + ParameterList, + Parent, + ReturnType, + TypeParameterList +} from '@flex-development/docast' + +/** + * Info associated with call signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface CallSignatureData extends Data {} + +/** + * A call signature. + * + * @example + * (item: T): T + * @example + * (arr: number[]): number + * @example + * (str: string) + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface CallSignature extends Parent { + /** + * List of children. + * + * @see {@linkcode ParameterList} + * @see {@linkcode ReturnType} + * @see {@linkcode TypeParameterList} + */ + children: + | [params: ParameterList, returnType: ReturnType] + | [params: ParameterList] + | [typeParams: TypeParameterList, params: ParameterList, ret: ReturnType] + | [typeParams: TypeParameterList, params: ParameterList] + + /** + * Info from the ecosystem. + * + * @see {@linkcode CallSignatureData} + */ + data?: CallSignatureData | undefined + + /** + * Node type. + */ + type: 'callSignature' +} + +export type { CallSignatureData, CallSignature as default } diff --git a/src/nodes/signature-construct.ts b/src/nodes/signature-construct.ts new file mode 100644 index 00000000..cefdf7f0 --- /dev/null +++ b/src/nodes/signature-construct.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - ConstructSignature + * @module docast/nodes/ConstructSignature + */ + +import type { CallSignature, Data, Parent } from '@flex-development/docast' + +/** + * Info associated with construct signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ConstructSignatureData extends Data {} + +/** + * A construct signature. + * + * @example + * new (s: string): SomeObject + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface ConstructSignature extends Parent { + /** + * List of children. + * + * @see {@linkcode CallSignature} + */ + children: [call: CallSignature] + + /** + * Info from the ecosystem. + * + * @see {@linkcode ConstructSignatureData} + */ + data?: ConstructSignatureData | undefined + + /** + * Node type. + */ + type: 'constructSignature' +} + +export type { ConstructSignatureData, ConstructSignature as default } diff --git a/src/nodes/signature-index.ts b/src/nodes/signature-index.ts new file mode 100644 index 00000000..4fbe8e4b --- /dev/null +++ b/src/nodes/signature-index.ts @@ -0,0 +1,60 @@ +/** + * @file Nodes - IndexSignature + * @module docast/nodes/IndexSignature + */ + +import type { + Data, + Indexer, + ModifierList, + Parent, + TypeAnnotation +} from '@flex-development/docast' + +/** + * Info associated with index signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface IndexSignatureData extends Data {} + +/** + * An index signature. + * + * @example + * [index: number]: string + * @example + * readonly [index: number]: string + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface IndexSignature extends Parent { + /** + * List of children. + * + * @see {@linkcode Indexer} + * @see {@linkcode ModifierList} + * @see {@linkcode TypeAnnotation} + */ + children: + | [modifiers: ModifierList, operation: Indexer, type: TypeAnnotation] + | [operation: Indexer, type: TypeAnnotation] + + /** + * Info from the ecosystem. + * + * @see {@linkcode IndexSignatureData} + */ + data?: IndexSignatureData | undefined + + /** + * Node type. + */ + type: 'indexSignature' +} + +export type { IndexSignature as default, IndexSignatureData } diff --git a/src/nodes/signature-mapped.ts b/src/nodes/signature-mapped.ts new file mode 100644 index 00000000..aa3929fd --- /dev/null +++ b/src/nodes/signature-mapped.ts @@ -0,0 +1,91 @@ +/** + * @file Nodes - MappedSignature + * @module docast/nodes/MappedSignature + */ + +import type { + Data, + Mapper, + MinusToken, + Parent, + PlusToken, + ReadonlyModifier, + TypeAnnotation +} from '@flex-development/docast' + +/** + * Info associated with mapped signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface MappedSignatureData extends Data {} + +/** + * An mapped signature. + * + * @example + * [Property in keyof Type]: Type[Property] + * @example + * [Property in keyof Type]-?: Type[Property] + * @example + * [Property in keyof Type]+?: Type[Property] + * @example + * readonly [Property in keyof Type]: Type[Property] + * @example + * -readonly [Property in keyof Type]: Type[Property] + * @example + * +readonly [Property in keyof Type]: Type[Property] + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface MappedSignature extends Parent { + /** + * List of children. + * + * @see {@linkcode Mapper} + * @see {@linkcode ReadonlyModifier} + * @see {@linkcode MinusToken} + * @see {@linkcode PlusToken} + * @see {@linkcode TypeAnnotation} + */ + children: + | [operation: Mapper, type: TypeAnnotation] + | [ + readonly: ReadonlyModifier, + operation: Mapper, + token: MinusToken | PlusToken, + type: TypeAnnotation + ] + | [readonly: ReadonlyModifier, operation: Mapper, type: TypeAnnotation] + | [ + token: MinusToken | PlusToken, + readonly: ReadonlyModifier, + operation: Mapper, + token: MinusToken | PlusToken, + type: TypeAnnotation + ] + | [ + token: MinusToken | PlusToken, + readonly: ReadonlyModifier, + operation: Mapper, + type: TypeAnnotation + ] + + /** + * Info from the ecosystem. + * + * @see {@linkcode MappedSignatureData} + */ + data?: MappedSignatureData | undefined + + /** + * Node type. + */ + type: 'mappedSignature' +} + +export type { MappedSignature as default, MappedSignatureData } diff --git a/src/nodes/signature-method.ts b/src/nodes/signature-method.ts new file mode 100644 index 00000000..e149a896 --- /dev/null +++ b/src/nodes/signature-method.ts @@ -0,0 +1,69 @@ +/** + * @file Nodes - MethodSignature + * @module docast/nodes/MethodSignature + */ + +import type { + CallSignature, + ComputedPropertyName, + Data, + ModifierList, + Parent, + PropertyName +} from '@flex-development/docast' + +/** + * Info associated with method signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface MethodSignatureData extends Data {} + +/** + * A method signature. + * + * @example + * enter(type: TokenType, fields?: TokenFields | null): Token + * @example + * get code(): Code + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface MethodSignature extends Parent { + /** + * List of children. + * + * @see {@linkcode CallSignature} + * @see {@linkcode ComputedPropertyName} + * @see {@linkcode ModifierList} + * @see {@linkcode PropertyName} + */ + children: + | [ + modifiers: ModifierList, + name: ComputedPropertyName | PropertyName, + call: CallSignature + ] + | [ + name: ComputedPropertyName | PropertyName, + call: CallSignature + ] + + /** + * Info from the ecosystem. + * + * @see {@linkcode MethodSignatureData} + */ + data?: MethodSignatureData | undefined + + /** + * Node type. + */ + type: 'methodSignature' +} + +export type { MethodSignature as default, MethodSignatureData } diff --git a/src/nodes/signature-property.ts b/src/nodes/signature-property.ts new file mode 100644 index 00000000..4349081f --- /dev/null +++ b/src/nodes/signature-property.ts @@ -0,0 +1,69 @@ +/** + * @file Nodes - PropertySignature + * @module docast/nodes/PropertySignature + */ + +import type { + ComputedPropertyName, + Data, + ModifierList, + Parent, + PropertyName, + TypeAnnotation +} from '@flex-development/docast' + +/** + * Info associated with property signatures. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface PropertySignatureData extends Data {} + +/** + * A property signature. + * + * @example + * children: Node[] + * @example + * type: string + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface PropertySignature extends Parent { + /** + * List of children. + * + * @see {@linkcode ComputedPropertyName} + * @see {@linkcode ModifierList} + * @see {@linkcode PropertyName} + * @see {@linkcode TypeAnnotation} + */ + children: + | [ + modifiers: ModifierList, + name: ComputedPropertyName | PropertyName, + type: TypeAnnotation + ] + | [ + name: ComputedPropertyName | PropertyName, + type: TypeAnnotation + ] + + /** + * Info from the ecosystem. + * + * @see {@linkcode PropertySignatureData} + */ + data?: PropertySignatureData | undefined + + /** + * Node type. + */ + type: 'propertySignature' +} + +export type { PropertySignature as default, PropertySignatureData } diff --git a/src/nodes/super.ts b/src/nodes/super.ts new file mode 100644 index 00000000..3676e920 --- /dev/null +++ b/src/nodes/super.ts @@ -0,0 +1,38 @@ +/** + * @file Nodes - Super + * @module docast/nodes/Super + */ + +import type { Data, Node } from '@flex-development/docast' + +/** + * Info associated with `super` keywords. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface SuperData extends Data {} + +/** + * The `super` keyword. + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface Super extends Node { + /** + * Info from the ecosystem. + * + * @see {@linkcode SuperData} + */ + data?: SuperData | undefined + + /** + * Node type. + */ + type: 'super' +} + +export type { Super as default, SuperData } diff --git a/src/nodes/template-element.ts b/src/nodes/template-element.ts new file mode 100644 index 00000000..c0c86828 --- /dev/null +++ b/src/nodes/template-element.ts @@ -0,0 +1,43 @@ +/** + * @file Nodes - TemplateElement + * @module docast/nodes/TemplateElement + */ + +import type { Data, Literal } from '@flex-development/docast' + +/** + * Info associated with template literal elements. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TemplateElementData extends Data {} + +/** + * A template literal element. + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface TemplateElement extends Literal { + /** + * Info from the ecosystem. + * + * @see {@linkcode TemplateElementData} + */ + data?: TemplateElementData | undefined + + /** + * Node type. + */ + type: 'templateElement' + + /** + * Raw template element value. + */ + value: string +} + +export type { TemplateElement as default, TemplateElementData } diff --git a/src/nodes/template-literal.ts b/src/nodes/template-literal.ts new file mode 100644 index 00000000..9cc2147f --- /dev/null +++ b/src/nodes/template-literal.ts @@ -0,0 +1,52 @@ +/** + * @file Nodes - TemplateLiteral + * @module docast/nodes/TemplateLiteral + */ + +import type { + Data, + Parent, + TemplateElement, + TemplatePlaceholder +} from '@flex-development/docast' + +/** + * Info associated with template literals. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TemplateLiteralData extends Data {} + +/** + * A template literal. + * + * @see {@linkcode Parent} + * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals + * + * @extends {Parent} + */ +interface TemplateLiteral extends Parent { + /** + * List of children. + * + * @see {@linkcode TemplateElement} + * @see {@linkcode TemplatePlaceholder} + */ + children: (TemplateElement | TemplatePlaceholder)[] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TemplateLiteralData} + */ + data?: TemplateLiteralData | undefined + + /** + * Node type. + */ + type: 'templateLiteral' +} + +export type { TemplateLiteral as default, TemplateLiteralData } diff --git a/src/nodes/template-placeholder.ts b/src/nodes/template-placeholder.ts new file mode 100644 index 00000000..4ea35e0c --- /dev/null +++ b/src/nodes/template-placeholder.ts @@ -0,0 +1,45 @@ +/** + * @file Nodes - TemplatePlaceholder + * @module docast/nodes/TemplatePlaceholder + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with template literal placeholders. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TemplatePlaceholderData extends Data {} + +/** + * A template literal placeholder (`${expression}`). + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TemplatePlaceholder extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [expression: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TemplatePlaceholderData} + */ + data?: TemplatePlaceholderData | undefined + + /** + * Node type. + */ + type: 'templatePlaceholder' +} + +export type { TemplatePlaceholder as default, TemplatePlaceholderData } diff --git a/src/nodes/this.ts b/src/nodes/this.ts new file mode 100644 index 00000000..41765664 --- /dev/null +++ b/src/nodes/this.ts @@ -0,0 +1,38 @@ +/** + * @file Nodes - This + * @module docast/nodes/This + */ + +import type { Data, Node } from '@flex-development/docast' + +/** + * Info associated with `this` keywords. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface ThisData extends Data {} + +/** + * The `this` keyword. + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface This extends Node { + /** + * Info from the ecosystem. + * + * @see {@linkcode ThisData} + */ + data?: ThisData | undefined + + /** + * Node type. + */ + type: 'this' +} + +export type { This as default, ThisData } diff --git a/src/nodes/token-ellipsis.ts b/src/nodes/token-ellipsis.ts new file mode 100644 index 00000000..b0eb57ad --- /dev/null +++ b/src/nodes/token-ellipsis.ts @@ -0,0 +1,22 @@ +/** + * @file Nodes - EllipsisToken + * @module docast/nodes/EllipsisToken + */ + +import type { Node } from '@flex-development/docast' + +/** + * An ellipsis (`...`). + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface EllipsisToken extends Node { + /** + * Node type. + */ + type: 'ellipsisToken' +} + +export type { EllipsisToken as default } diff --git a/src/nodes/token-minus.ts b/src/nodes/token-minus.ts new file mode 100644 index 00000000..a9ee4a7c --- /dev/null +++ b/src/nodes/token-minus.ts @@ -0,0 +1,22 @@ +/** + * @file Nodes - MinusToken + * @module docast/nodes/MinusToken + */ + +import type { Node } from '@flex-development/docast' + +/** + * A minus sign (`-`). + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface MinusToken extends Node { + /** + * Node type. + */ + type: 'minusToken' +} + +export type { MinusToken as default } diff --git a/src/nodes/token-plus.ts b/src/nodes/token-plus.ts new file mode 100644 index 00000000..f1aa77ec --- /dev/null +++ b/src/nodes/token-plus.ts @@ -0,0 +1,22 @@ +/** + * @file Nodes - PlusToken + * @module docast/nodes/PlusToken + */ + +import type { Node } from '@flex-development/docast' + +/** + * A plus sign (`+`). + * + * @see {@linkcode Node} + * + * @extends {Node} + */ +interface PlusToken extends Node { + /** + * Node type. + */ + type: 'plusToken' +} + +export type { PlusToken as default } diff --git a/src/nodes/tuple-element.ts b/src/nodes/tuple-element.ts new file mode 100644 index 00000000..131668f8 --- /dev/null +++ b/src/nodes/tuple-element.ts @@ -0,0 +1,63 @@ +/** + * @file Nodes - TupleElement + * @module docast/nodes/TupleElement + */ + +import type { + Data, + EllipsisToken, + Identifier, + Parent, + TypeAnnotation, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with tuple elements. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TupleElementData extends Data {} + +/** + * A tuple element. + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TupleElement extends Parent { + /** + * List of children. + * + * @see {@linkcode EllipsisToken} + * @see {@linkcode Identifier} + * @see {@linkcode TypeAnnotation} + * @see {@linkcode TypeExpression} + */ + children: + | [ellipsis: EllipsisToken, label: Identifier, type: TypeAnnotation] + | [label: Identifier, type: TypeAnnotation] + | [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TupleElementData} + */ + data?: TupleElementData | undefined + + /** + * Boolean indicating optional tuple element. + */ + optional: boolean + + /** + * Node type. + */ + type: 'tupleElement' +} + +export type { TupleElement as default, TupleElementData } diff --git a/src/nodes/tuple-type.ts b/src/nodes/tuple-type.ts new file mode 100644 index 00000000..448e24d2 --- /dev/null +++ b/src/nodes/tuple-type.ts @@ -0,0 +1,49 @@ +/** + * @file Nodes - TupleType + * @module docast/nodes/TupleType + */ + +import type { + Data, + Parent, + TupleElement +} from '@flex-development/docast' + +/** + * Info associated with tuple types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TupleTypeData extends Data {} + +/** + * A tuple type. + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TupleType extends Parent { + /** + * List of children. + * + * @see {@linkcode TupleElement} + */ + children: TupleElement[] | [] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TupleTypeData} + */ + data?: TupleTypeData | undefined + + /** + * Node type. + */ + type: 'tupleType' +} + +export type { TupleType as default, TupleTypeData } diff --git a/src/nodes/type-annotation.ts b/src/nodes/type-annotation.ts new file mode 100644 index 00000000..4dac6cb5 --- /dev/null +++ b/src/nodes/type-annotation.ts @@ -0,0 +1,50 @@ +/** + * @file Nodes - TypeAnnotation + * @module docast/nodes/TypeAnnotation + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with type annotations. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeAnnotationData extends Data {} + +/** + * A type annotation. + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeAnnotation extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeAnnotationData} + */ + data?: TypeAnnotationData | undefined + + /** + * Boolean indicating if an optional type is being annotated. + */ + optional?: boolean | null | undefined + + /** + * Node type. + */ + type: 'typeAnnotation' +} + +export type { TypeAnnotation as default, TypeAnnotationData } diff --git a/src/nodes/type-argument-list.ts b/src/nodes/type-argument-list.ts new file mode 100644 index 00000000..7c98e440 --- /dev/null +++ b/src/nodes/type-argument-list.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - TypeArgumentList + * @module docast/nodes/TypeArgumentList + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with type argument lists. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeArgumentListData extends Data {} + +/** + * A type argument list. + * + * @example + * + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeArgumentList extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: TypeExpression[] | [] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeArgumentListData} + */ + data?: TypeArgumentListData | undefined + + /** + * Node type. + */ + type: 'typeArgumentList' +} + +export type { TypeArgumentList as default, TypeArgumentListData } diff --git a/src/nodes/type-expression.ts b/src/nodes/type-expression.ts deleted file mode 100644 index a0c3fecd..00000000 --- a/src/nodes/type-expression.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file Nodes - TypeExpression - * @module docast/nodes/TypeExpression - */ - -import type { Data, Literal } from '@flex-development/docast' -import type { Optional } from '@flex-development/tutils' - -/** - * Info associated with type expressions. - * - * @see {@linkcode Data} - * - * @extends {Data} - */ -interface TypeExpressionData extends Data {} - -/** - * A type definition or constraint denoted in block tag **tag content**. - * - * @see {@linkcode Literal} - * - * @extends {Literal} - */ -interface TypeExpression extends Literal { - /** - * Info from the ecosystem. - * - * @see {@linkcode TypeExpressionData} - */ - data?: Optional - - /** - * Node type. - */ - type: 'typeExpression' -} - -export type { TypeExpressionData, TypeExpression as default } diff --git a/src/nodes/type-metadata.ts b/src/nodes/type-metadata.ts new file mode 100644 index 00000000..0631e2b2 --- /dev/null +++ b/src/nodes/type-metadata.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - TypeMetadata + * @module docast/nodes/TypeMetadata + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with type metadata. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeMetadataData extends Data {} + +/** + * An inlined type expression. + * + * @example + * {number} + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeMetadata extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeMetadataData} + */ + data?: TypeMetadataData | undefined + + /** + * Node type. + */ + type: 'typeMetadata' +} + +export type { TypeMetadata as default, TypeMetadataData } diff --git a/src/nodes/type-operation.ts b/src/nodes/type-operation.ts new file mode 100644 index 00000000..94831396 --- /dev/null +++ b/src/nodes/type-operation.ts @@ -0,0 +1,57 @@ +/** + * @file Nodes - TypeOperation + * @module docast/nodes/TypeOperation + */ + +import type { + Data, + Parent, + TypeExpression, + TypeOperator +} from '@flex-development/docast' + +/** + * Info associated with type operations. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeOperationData extends Data {} + +/** + * A type operation. + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeOperation extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeOperationData} + */ + data?: TypeOperationData | undefined + + /** + * Type operator. + * + * @see {@linkcode TypeOperator} + */ + operator: TypeOperator + + /** + * Node type. + */ + type: 'typeOperation' +} + +export type { TypeOperation as default, TypeOperationData } diff --git a/src/nodes/type-parameter-list.ts b/src/nodes/type-parameter-list.ts new file mode 100644 index 00000000..0a2a83eb --- /dev/null +++ b/src/nodes/type-parameter-list.ts @@ -0,0 +1,48 @@ +/** + * @file Nodes - TypeParameterList + * @module docast/nodes/TypeParameterList + */ + +import type { Data, Parent, TypeParameter } from '@flex-development/docast' + +/** + * Info associated with type parameter lists. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeParameterListData extends Data {} + +/** + * A type parameter list. + * + * @example + * + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeParameterList extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeParameter} + */ + children: TypeParameter[] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeParameterListData} + */ + data?: TypeParameterListData | undefined + + /** + * Node type. + */ + type: 'typeParameterList' +} + +export type { TypeParameterList as default, TypeParameterListData } diff --git a/src/nodes/type-parameter.ts b/src/nodes/type-parameter.ts new file mode 100644 index 00000000..14352ff5 --- /dev/null +++ b/src/nodes/type-parameter.ts @@ -0,0 +1,89 @@ +/** + * @file Nodes - TypeParameter + * @module docast/nodes/TypeParameter + */ + +import type { + Data, + ExtendsPredicate, + Identifier, + ModifierList, + Parent, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with type parameters. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypeParameterData extends Data {} + +/** + * A type parameter. + * + * @example + * T extends number = 0 + * @example + * T extends number + * @example + * const T + * @example + * T + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypeParameter extends Parent { + /** + * List of children. + * + * @see {@linkcode ExtendsPredicate} + * @see {@linkcode Identifier} + * @see {@linkcode ModifierList} + * @see {@linkcode TypeExpression} + */ + children: + | [ + modifiers: ModifierList, + parameter: Identifier, + extend: ExtendsPredicate + ] + | [ + modifiers: ModifierList, + parameter: Identifier, + extend: ExtendsPredicate, + fallback: TypeExpression + ] + | [ + modifiers: ModifierList, + parameter: Identifier, + fallback: TypeExpression + ] + | [ + parameter: Identifier, + extend: ExtendsPredicate, + fallback: TypeExpression + ] + | [modifiers: ModifierList, parameter: Identifier] + | [parameter: Identifier, extend: ExtendsPredicate] + | [parameter: Identifier, fallback: TypeExpression] + | [parameter: Identifier] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypeParameterData} + */ + data?: TypeParameterData | undefined + + /** + * Node type. + */ + type: 'typeParameter' +} + +export type { TypeParameter as default, TypeParameterData } diff --git a/src/nodes/type-predicate.ts b/src/nodes/type-predicate.ts new file mode 100644 index 00000000..722e587c --- /dev/null +++ b/src/nodes/type-predicate.ts @@ -0,0 +1,56 @@ +/** + * @file Nodes - TypePredicate + * @module docast/nodes/TypePredicate + */ + +import type { + Data, + Identifier, + Parent, + This, + TypeExpression +} from '@flex-development/docast' + +/** + * Info associated with type predicates. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface TypePredicateData extends Data {} + +/** + * A type predicate. + * + * @example + * value is Type + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface TypePredicate extends Parent { + /** + * List of children. + * + * @see {@linkcode Identifier} + * @see {@linkcode This} + * @see {@linkcode TypeExpression} + */ + children: [value: Identifier | This, type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode TypePredicateData} + */ + data?: TypePredicateData | undefined + + /** + * Node type. + */ + type: 'typePredicate' +} + +export type { TypePredicate as default, TypePredicateData } diff --git a/src/nodes/type-symbol.ts b/src/nodes/type-symbol.ts new file mode 100644 index 00000000..974f815e --- /dev/null +++ b/src/nodes/type-symbol.ts @@ -0,0 +1,36 @@ +/** + * @file Nodes - TypeSymbol + * @module docast/nodes/TypeSymbol + */ + +import type { Literal, TypeSymbolValue } from '@flex-development/docast' + +/** + * A type symbol. + * + * @example + * * + * @example + * object + * @example + * void + * + * @see {@linkcode Literal} + * + * @extends {Literal} + */ +interface TypeSymbol extends Literal { + /** + * Node type. + */ + type: 'typeSymbol' + + /** + * The type symbol. + * + * @see {@linkcode TypeSymbolValue} + */ + value: TypeSymbolValue +} + +export type { TypeSymbol as default } diff --git a/src/nodes/union-type.ts b/src/nodes/union-type.ts new file mode 100644 index 00000000..45acfb42 --- /dev/null +++ b/src/nodes/union-type.ts @@ -0,0 +1,45 @@ +/** + * @file Nodes - UnionType + * @module docast/nodes/UnionType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with union types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface UnionTypeData extends Data {} + +/** + * A union type (`boolean | null | undefined`). + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface UnionType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [left: TypeExpression, right: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode UnionTypeData} + */ + data?: UnionTypeData | undefined + + /** + * Node type. + */ + type: 'unionType' +} + +export type { UnionType as default, UnionTypeData } diff --git a/src/nodes/variadic-type.ts b/src/nodes/variadic-type.ts new file mode 100644 index 00000000..b6dfecff --- /dev/null +++ b/src/nodes/variadic-type.ts @@ -0,0 +1,45 @@ +/** + * @file Nodes - VariadicType + * @module docast/nodes/VariadicType + */ + +import type { Data, Parent, TypeExpression } from '@flex-development/docast' + +/** + * Info associated with variadic types. + * + * @see {@linkcode Data} + * + * @extends {Data} + */ +interface VariadicTypeData extends Data {} + +/** + * A variadic type (`...number`). + * + * @see {@linkcode Parent} + * + * @extends {Parent} + */ +interface VariadicType extends Parent { + /** + * List of children. + * + * @see {@linkcode TypeExpression} + */ + children: [type: TypeExpression] + + /** + * Info from the ecosystem. + * + * @see {@linkcode VariadicTypeData} + */ + data?: VariadicTypeData | undefined + + /** + * Node type. + */ + type: 'variadicType' +} + +export type { VariadicType as default, VariadicTypeData } diff --git a/src/types/__tests__/modifier-keyword.spec-d.ts b/src/types/__tests__/modifier-keyword.spec-d.ts new file mode 100644 index 00000000..34fd44ce --- /dev/null +++ b/src/types/__tests__/modifier-keyword.spec-d.ts @@ -0,0 +1,32 @@ +/** + * @file Type Tests - ModifierKeyword + * @module docast/types/tests/unit-d/ModifierKeyword + */ + +import type TestSubject from '../modifier-keyword' + +describe('unit-d:types/ModifierKeyword', () => { + it('should extract "const"', () => { + expectTypeOf().extract<'const'>().not.toBeNever() + }) + + it('should extract "get"', () => { + expectTypeOf().extract<'get'>().not.toBeNever() + }) + + it('should extract "in"', () => { + expectTypeOf().extract<'in'>().not.toBeNever() + }) + + it('should extract "out"', () => { + expectTypeOf().extract<'out'>().not.toBeNever() + }) + + it('should extract "readonly"', () => { + expectTypeOf().extract<'readonly'>().not.toBeNever() + }) + + it('should extract "set"', () => { + expectTypeOf().extract<'set'>().not.toBeNever() + }) +}) diff --git a/src/types/__tests__/property-name.spec-d.ts b/src/types/__tests__/property-name.spec-d.ts new file mode 100644 index 00000000..2365d7df --- /dev/null +++ b/src/types/__tests__/property-name.spec-d.ts @@ -0,0 +1,25 @@ +/** + * @file Type Tests - PropertyName + * @module docast/types/tests/unit-d/PropertyName + */ + +import type { + Identifier, + NumberLiteral, + StringLiteral +} from '@flex-development/docast' +import type TestSubject from '../property-name' + +describe('unit-d:types/PropertyName', () => { + it('should extract Identifier', () => { + expectTypeOf().extract().not.toBeNever() + }) + + it('should extract NumberLiteral', () => { + expectTypeOf().extract().not.toBeNever() + }) + + it('should extract StringLiteral', () => { + expectTypeOf().extract().not.toBeNever() + }) +}) diff --git a/src/types/__tests__/type-operator.spec-d.ts b/src/types/__tests__/type-operator.spec-d.ts new file mode 100644 index 00000000..c1602ab9 --- /dev/null +++ b/src/types/__tests__/type-operator.spec-d.ts @@ -0,0 +1,24 @@ +/** + * @file Type Tests - TypeOperator + * @module docast/types/tests/unit-d/TypeOperator + */ + +import type TestSubject from '../type-operator' + +describe('unit-d:types/TypeOperator', () => { + it('should extract "keyof"', () => { + expectTypeOf().extract<'keyof'>().not.toBeNever() + }) + + it('should extract "readonly"', () => { + expectTypeOf().extract<'readonly'>().not.toBeNever() + }) + + it('should extract "typeof"', () => { + expectTypeOf().extract<'typeof'>().not.toBeNever() + }) + + it('should extract "unique"', () => { + expectTypeOf().extract<'unique'>().not.toBeNever() + }) +}) diff --git a/src/types/__tests__/type-symbol-value.spec-d.ts b/src/types/__tests__/type-symbol-value.spec-d.ts new file mode 100644 index 00000000..3b26e600 --- /dev/null +++ b/src/types/__tests__/type-symbol-value.spec-d.ts @@ -0,0 +1,52 @@ +/** + * @file Type Tests - TypeSymbolValue + * @module docast/types/tests/unit-d/TypeSymbolValue + */ + +import type TestSubject from '../type-symbol-value' + +describe('unit-d:types/TypeSymbolValue', () => { + it('should extract "*"', () => { + expectTypeOf().extract<'*'>().not.toBeNever() + }) + + it('should extract "any"', () => { + expectTypeOf().extract<'any'>().not.toBeNever() + }) + + it('should extract "bigint"', () => { + expectTypeOf().extract<'bigint'>().not.toBeNever() + }) + + it('should extract "boolean"', () => { + expectTypeOf().extract<'boolean'>().not.toBeNever() + }) + + it('should extract "never"', () => { + expectTypeOf().extract<'never'>().not.toBeNever() + }) + + it('should extract "number"', () => { + expectTypeOf().extract<'number'>().not.toBeNever() + }) + + it('should extract "object"', () => { + expectTypeOf().extract<'object'>().not.toBeNever() + }) + + it('should extract "string"', () => { + expectTypeOf().extract<'string'>().not.toBeNever() + }) + + it('should extract "symbol"', () => { + expectTypeOf().extract<'symbol'>().not.toBeNever() + }) + + it('should extract "unknown"', () => { + expectTypeOf().extract<'unknown'>().not.toBeNever() + }) + + it('should extract "void"', () => { + expectTypeOf().extract<'void'>().not.toBeNever() + }) +}) diff --git a/src/types/index.ts b/src/types/index.ts index 721ce2e4..d72be29e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -6,4 +6,8 @@ export type { default as AnyNode } from './any-node' export type { default as AnyParent } from './any-parent' export type { default as Child } from './child' +export type { default as ModifierKeyword } from './modifier-keyword' +export type { default as PropertyName } from './property-name' export type { default as TagName } from './tag-name' +export type { default as TypeOperator } from './type-operator' +export type { default as TypeSymbolValue } from './type-symbol-value' diff --git a/src/types/modifier-keyword.ts b/src/types/modifier-keyword.ts new file mode 100644 index 00000000..ca0a2f00 --- /dev/null +++ b/src/types/modifier-keyword.ts @@ -0,0 +1,11 @@ +/** + * @file Type Aliases - ModifierKeyword + * @module docast/types/ModifierKeyword + */ + +/** + * Modifier keywords. + */ +type ModifierKeyword = 'const' | 'get' | 'in' | 'out' | 'readonly' | 'set' + +export type { ModifierKeyword as default } diff --git a/src/types/property-name.ts b/src/types/property-name.ts new file mode 100644 index 00000000..1febb153 --- /dev/null +++ b/src/types/property-name.ts @@ -0,0 +1,21 @@ +/** + * @file Type Aliases - PropertyName + * @module docast/types/PropertyName + */ + +import type { + Identifier, + NumberLiteral, + StringLiteral +} from '@flex-development/docast' + +/** + * Union of nodes representing non-computed property names. + * + * @see {@linkcode Identifier} + * @see {@linkcode NumberLiteral} + * @see {@linkcode StringLiteral} + */ +type PropertyName = Identifier | NumberLiteral | StringLiteral + +export type { PropertyName as default } diff --git a/src/types/type-operator.ts b/src/types/type-operator.ts new file mode 100644 index 00000000..3eb00172 --- /dev/null +++ b/src/types/type-operator.ts @@ -0,0 +1,11 @@ +/** + * @file Type Aliases - TypeOperator + * @module docast/types/TypeOperator + */ + +/** + * Type operators. + */ +type TypeOperator = 'keyof' | 'readonly' | 'typeof' | 'unique' + +export type { TypeOperator as default } diff --git a/src/types/type-symbol-value.ts b/src/types/type-symbol-value.ts new file mode 100644 index 00000000..b690f83c --- /dev/null +++ b/src/types/type-symbol-value.ts @@ -0,0 +1,22 @@ +/** + * @file Type Aliases - TypeSymbolValue + * @module docast/types/TypeSymbolValue + */ + +/** + * Union of type symbols. + */ +type TypeSymbolValue = + | '*' + | 'any' + | 'bigint' + | 'boolean' + | 'never' + | 'number' + | 'object' + | 'string' + | 'symbol' + | 'unknown' + | 'void' + +export type { TypeSymbolValue as default }