UNPKG

@ts-ast-parser/core

Version:

Reflects a simplified version of the TypeScript AST for generating documentation

49 lines 1.65 kB
import type { ProjectContext } from './project-context.js'; import type { Type, TypeKind } from './models/type.js'; import type { RootNodeType } from './models/node.js'; import type ts from 'typescript'; /** * Base specification of what a reflected node should have. */ export interface ReflectedNode<Model extends object = object, T extends ts.Node | ts.Signature = ts.Node> { /** * The original node generated by the TypeScript compiler */ getTSNode(): T | null; /** * Returns the context in which the AST node was created. * The context contains useful utilities like the TS type checker. */ getContext(): ProjectContext; /** * Returns a simple readonly JavaScript object without methods or internal state. */ serialize(): Model; } /** * Represents a top level node (import, export or declaration) */ export interface ReflectedRootNode<Model extends object = object, T extends ts.Node | ts.Signature = ts.Node> extends ReflectedNode<Model, T> { /** * The type of node. Can be an import, an export or a declaration */ getNodeType(): RootNodeType; } /** * Base specification of what a reflected type should have. */ export interface ReflectedTypeNode<T extends ts.TypeNode = ts.TypeNode> extends ReflectedNode<Type, T> { /** * The type representation as text */ getText(): string; /** * The original type generated by the TypeScript compiler */ getTSType(): ts.Type; /** * The kind of type (intersection, union, conditional, literal, etc...) */ getKind(): TypeKind; } //# sourceMappingURL=reflected-node.d.ts.map