UNPKG

3.8 kBTypeScriptView Raw
1import ts from "typescript";
2import { type Reflection, type ProjectReflection, DeclarationReflection, type DocumentReflection, ReflectionKind } from "../models/index";
3import type { Converter } from "./converter";
4import type { TranslationProxy } from "../internationalization/internationalization";
5/**
6 * The context describes the current state the converter is in.
7 */
8export declare class Context {
9 /**
10 * The converter instance that has created the context.
11 */
12 readonly converter: Converter;
13 /**
14 * The TypeChecker instance returned by the TypeScript compiler.
15 */
16 get checker(): ts.TypeChecker;
17 /**
18 * Translation interface for log messages.
19 */
20 get i18n(): TranslationProxy;
21 /**
22 * The program currently being converted.
23 * Accessing this property will throw if a source file is not currently being converted.
24 */
25 get program(): ts.Program;
26 private _program?;
27 /**
28 * All programs being converted.
29 */
30 readonly programs: readonly ts.Program[];
31 /**
32 * The project that is currently processed.
33 */
34 readonly project: ProjectReflection;
35 /**
36 * The scope or parent reflection that is currently processed.
37 */
38 readonly scope: Reflection;
39 convertingTypeNode: boolean;
40 convertingClassOrInterface: boolean;
41 shouldBeStatic: boolean;
42 /**
43 * Create a new Context instance.
44 *
45 * @param converter The converter instance that has created the context.
46 * @internal
47 */
48 constructor(converter: Converter, programs: readonly ts.Program[], project: ProjectReflection, scope?: Context["scope"]);
49 /** @internal */
50 get logger(): import("../utils").Logger;
51 /**
52 * Return the type declaration of the given node.
53 *
54 * @param node The TypeScript node whose type should be resolved.
55 * @returns The type declaration of the given node.
56 */
57 getTypeAtLocation(node: ts.Node): ts.Type | undefined;
58 getSymbolAtLocation(node: ts.Node): ts.Symbol | undefined;
59 expectSymbolAtLocation(node: ts.Node): ts.Symbol;
60 resolveAliasedSymbol(symbol: ts.Symbol): ts.Symbol;
61 createDeclarationReflection(kind: ReflectionKind, symbol: ts.Symbol | undefined, exportSymbol: ts.Symbol | undefined, nameOverride?: string): DeclarationReflection;
62 postReflectionCreation(reflection: Reflection, symbol: ts.Symbol | undefined, exportSymbol: ts.Symbol | undefined): void;
63 finalizeDeclarationReflection(reflection: DeclarationReflection): void;
64 addChild(reflection: DeclarationReflection | DocumentReflection): void;
65 shouldIgnore(symbol: ts.Symbol): boolean;
66 /**
67 * Register a newly generated reflection. All created reflections should be
68 * passed to this method to ensure that the project helper functions work correctly.
69 *
70 * @param reflection The reflection that should be registered.
71 * @param symbol The symbol the given reflection was resolved from.
72 */
73 registerReflection(reflection: Reflection, symbol: ts.Symbol | undefined): void;
74 /** @internal */
75 setActiveProgram(program: ts.Program | undefined): void;
76 getComment(symbol: ts.Symbol, kind: ReflectionKind): import("../models/index").Comment | undefined;
77 getNodeComment(node: ts.Node, moduleComment: boolean): import("../models/index").Comment | undefined;
78 getFileComment(node: ts.SourceFile): import("../models/index").Comment | undefined;
79 getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag): import("../models/index").Comment | undefined;
80 getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature): import("../models/index").Comment | undefined;
81 withScope(scope: Reflection): Context;
82}