UNPKG

@ts-ast-parser/core

Version:

Reflects a simplified version of the TypeScript AST for generating documentation

177 lines 5.5 kB
import { ExpressionWithTypeArgumentsNode } from './expression-with-type-arguments-node.js'; import { DeclarationKind } from '../models/declaration-kind.js'; import type { ProjectContext } from '../project-context.js'; import type { DeclarationNode } from './declaration-node.js'; import { TypeParameterNode } from './type-parameter-node.js'; import type { ClassDeclaration } from '../models/class.js'; import { SignatureNode } from './signature-node.js'; import { DecoratorNode } from './decorator-node.js'; import { FunctionNode } from './function-node.js'; import { PropertyNode } from './property-node.js'; import { RootNodeType } from '../models/node.js'; import { CommentNode } from './comment-node.js'; import ts from 'typescript'; /** * Reflected node that represents a ClassDeclaration or a ClassExpression */ export declare class ClassNode implements DeclarationNode<ClassDeclaration, ts.ClassDeclaration | ts.ClassExpression | ts.VariableStatement> { private readonly _node; private readonly _context; private readonly _instanceMembers; private readonly _staticMembers; private readonly _heritage; private readonly _jsDoc; constructor(node: ts.ClassDeclaration | ts.ClassExpression | ts.VariableStatement, context: ProjectContext); /** * The name of the class. * * If it's a class expression that it's assigned to a variable, it will return * the name of the variable * * @returns The name of the class */ getName(): string; /** * The reflected node type * * @returns The declaration kind */ getNodeType(): RootNodeType; /** * The reflected declaration kind * * @returns The class declaration kind */ getKind(): DeclarationKind.Class; /** * The context includes useful APIs that are shared across * all the reflected symbols. * * Some APIs include the parsed configuration options, the * system interface, the type checker * * @returns The analyser context */ getContext(): ProjectContext; /** * The internal TypeScript node * * @returns The TypeScript AST node related to this reflected node */ getTSNode(): ts.ClassDeclaration | ts.ClassExpression | ts.VariableStatement; /** * The start line number position * * @returns The start line number position */ getLine(): number; /** * The namespace where the class has been defined. * * @returns The name of the namespace where this declaration is defined. * Will return an empty string if no namespace is found. */ getNamespace(): string; /** * The reflected JSDoc comment node * * @returns The JSDoc node */ getJSDoc(): CommentNode; /** * The reflected decorators applied to the class * * @returns An array of reflected decorators */ getDecorators(): DecoratorNode[]; /** * Finds a reflected decorator based on the name * * @param name - The decorator name to find * * @returns The reflected decorator that matches the given name */ getDecoratorWithName(name: string): DecoratorNode | null; /** * An array of constructors that can be used to * create an instance of the class * * @returns All the constructor signatures */ getConstructors(): SignatureNode[]; /** * The instance properties * * @returns All the reflected instance properties */ getProperties(): PropertyNode[]; /** * The static properties * * @returns All the reflected static properties */ getStaticProperties(): PropertyNode[]; /** * Finds an instance property based on the name * * @param name - The property name to find * * @returns The reflected instance property that matches the given name */ getPropertyWithName(name: string): PropertyNode | null; /** * The instance methods * * @returns All the reflected instance methods */ getMethods(): FunctionNode[]; /** * The static methods * * @returns All the reflected static methods */ getStaticMethods(): FunctionNode[]; /** * Finds an instance method based on the name * * @param name - The name of the method to find * * @returns The reflected instance method that matches the given name */ getMethodWithName(name: string): FunctionNode | null; /** * The type parameters * * @returns All the reflected type parameters */ getTypeParameters(): TypeParameterNode[]; /** * The heritage chain. Interfaces that the class implements or * parent classes that it extends. * * @returns The heritage chain */ getHeritage(): ExpressionWithTypeArgumentsNode[]; /** * Whether is a custom element or not * * @returns True if the class declaration is a custom element, otherwise false */ isCustomElement(): boolean; /** * Whether it's an abstract class or not * * @returns True if it's an abstract class, otherwise false */ isAbstract(): boolean; /** * Serializes the reflected node * * @returns The reflected node as a serializable object */ serialize(): ClassDeclaration; private _getPropertyMembers; private _getMethodMembers; private _getClassNode; } //# sourceMappingURL=class-node.d.ts.map