/** * Contains interfaces which describe the JSON output. Each interface is related to a specific type of serializer. * * ## Plugins * Plugins which modify the serialization process can use declaration merging * to add custom properties to the exported interfaces. * For example, if your custom serializer adds a property to all {@link Reflection} objects: * ```ts * declare module 'typedoc/dist/lib/serialization/schema' { * export interface AbstractReflection { * myCustomProp: boolean * } * } * ``` * * If a plugin defines a new Model type, {@link ModelToObject} will not pick up the serializer type and * the resulting type will not be included in the return type of {@link Serializer.toObject}. * To fix this, use declaration merging to augment the {@link Serializer} class. * ```ts * declare module 'typedoc/dist/lib/serialization/serializer' { * export interface Serializer { * toObject(value: CustomModel, obj?: Partial): CustomOutput * } * } * ``` * * For documentation on the JSON output properties, view the corresponding model. * @module */ import type * as M from "../models"; /** * Describes the mapping from Model types to the corresponding JSON output type. */ export type ModelToObject = T extends Array ? _ModelToObject[] : _ModelToObject; type _ModelToObject = T extends Primitive ? T : Required extends Required ? ReflectionGroup : Required extends Required ? ReflectionCategory : T extends M.SignatureReflection ? SignatureReflection : T extends M.ParameterReflection ? ParameterReflection : T extends M.DeclarationReflection ? DeclarationReflection : T extends M.TypeParameterReflection ? TypeParameterReflection : T extends M.ProjectReflection ? ProjectReflection : T extends M.ContainerReflection ? ContainerReflection : T extends M.ReferenceReflection ? ReferenceReflection : T extends M.Reflection ? Reflection : T extends M.SomeType ? TypeKindMap[T["type"]] : T extends M.Type ? SomeType : T extends M.Comment ? Comment : T extends M.CommentTag ? CommentTag : T extends M.CommentDisplayPart ? CommentDisplayPart : T extends M.SourceReference ? SourceReference : never; type Primitive = string | number | undefined | null | boolean; type ToSerialized = T extends Primitive ? T : T extends bigint ? { value: string; negative: boolean; } : ModelToObject; /** * Helper to describe a set of serialized properties. Primitive types are returned * directly, while other models are first passed through ModelToObject. * This helper removes the readonly modifier from properties since the result of serialization * is a plain object that consumers may modify as they choose, TypeDoc doesn't care. */ type S = { -readonly [K2 in K]: ToSerialized; }; export interface ReflectionSymbolId { sourceFileName: string; qualifiedName: string; } export interface ReflectionGroup extends S { children?: M.ReflectionGroup["children"][number]["id"][]; } export interface ReflectionCategory extends S { children?: M.ReflectionCategory["children"][number]["id"][]; } /** @category Reflections */ export type SomeReflection = { [K in keyof M.ReflectionVariant]: ModelToObject; }[keyof M.ReflectionVariant]; /** @category Reflections */ export interface ReferenceReflection extends Omit, S { /** * -1 if the reference refers to a symbol that does not exist in the documentation. * Otherwise, the reflection ID. */ target: number; } /** @category Reflections */ export interface SignatureReflection extends Omit, S { typeParameter?: ModelToObject; } /** @category Reflections */ export interface ParameterReflection extends Omit, S { variant: "param"; } /** @category Reflections */ export interface DeclarationReflection extends Omit, S { } /** @category Reflections */ export interface TypeParameterReflection extends Omit, S { } /** @category Reflections */ export interface ProjectReflection extends Omit, S { symbolIdMap: Record; } /** @category Reflections */ export interface ContainerReflection extends Reflection, S { } /** @category Reflections */ export interface Reflection extends S { flags: ReflectionFlags; } /** @category Types */ export type SomeType = ModelToObject; /** @category Types */ export type TypeKindMap = { array: ArrayType; conditional: ConditionalType; indexedAccess: IndexedAccessType; inferred: InferredType; intersection: IntersectionType; intrinsic: IntrinsicType; literal: LiteralType; mapped: MappedType; optional: OptionalType; predicate: PredicateType; query: QueryType; reference: ReferenceType; reflection: ReflectionType; rest: RestType; templateLiteral: TemplateLiteralType; tuple: TupleType; namedTupleMember: NamedTupleMemberType; typeOperator: TypeOperatorType; union: UnionType; unknown: UnknownType; }; /** @category Types */ export interface ArrayType extends Type, S { } /** @category Types */ export interface ConditionalType extends Type, S { } /** @category Types */ export interface IndexedAccessType extends Type, S { } /** @category Types */ export interface InferredType extends Type, S { } /** @category Types */ export interface IntersectionType extends Type, S { } /** @category Types */ export interface IntrinsicType extends Type, S { } /** @category Types */ export interface OptionalType extends Type, S { } /** @category Types */ export interface PredicateType extends Type, S { } /** @category Types */ export interface QueryType extends Type, S { } /** @category Types */ export interface ReferenceType extends Type, S { target: number | ReflectionSymbolId; qualifiedName?: string; refersToTypeParameter?: boolean; preferValues?: boolean; } /** @category Types */ export interface ReflectionType extends Type, S { } /** @category Types */ export interface RestType extends Type, S { } /** @category Types */ export interface LiteralType extends Type, S { } /** @category Types */ export interface TupleType extends Type, S { elements?: ModelToObject; } /** @category Types */ export interface NamedTupleMemberType extends Type, S { } /** @category Types */ export interface TemplateLiteralType extends Type, S { tail: [SomeType, string][]; } /** @category Types */ export interface MappedType extends Type, S { } /** @category Types */ export interface TypeOperatorType extends Type, S { } /** @category Types */ export interface UnionType extends Type, S { } /** @category Types */ export interface UnknownType extends Type, S { } /** @category Types */ export interface Type { } type BoolKeys = { [K in keyof T]-?: T[K] extends boolean ? K : never; }[keyof T]; export interface ReflectionFlags extends Partial>> { } /** @category Comments */ export interface Comment extends Partial> { summary: CommentDisplayPart[]; modifierTags?: `@${string}`[]; } /** @category Comments */ export interface CommentTag extends S { content: CommentDisplayPart[]; } /** @category Comments */ export type CommentDisplayPart = { kind: "text"; text: string; } | { kind: "code"; text: string; } | InlineTagDisplayPart; /** * If `target` is a number, it is a reflection ID. If a string, it is a URL. * `target` will only be set for `@link`, `@linkcode`, and `@linkplain` tags. * @category Comments */ export interface InlineTagDisplayPart { kind: "inline-tag"; tag: `@${string}`; text: string; target?: string | number | ReflectionSymbolId; tsLinkText?: string; } export interface SourceReference extends S { } export {};