types.ts

Metadata types for library source code analysis.

These types represent the structure of src/lib/ exports, extracted at build time via TypeScript compiler analysis. Used for generating API documentation and enabling code search.

Hierarchy: ModuleJson → DeclarationJson (discriminated union on kind) → MemberJson (discriminated union on kind)

Zod input/output split

Array fields use .default([]) so they're optional in serialized JSON (compact) but guaranteed [] at runtime after .parse(). Input types (ModuleJsonInput, DeclarationJsonInput, ComponentPropJsonInput) accept optional arrays; output types (ModuleJson, DeclarationJson, ComponentPropJson) guarantee arrays. Use compactReplacer (in declaration-helpers.ts) with JSON.stringify for compact output.

Discriminated union

DeclarationJson is a z.discriminatedUnion on kind with 9 variants: FunctionDeclarationJson, ClassDeclarationJson, InterfaceDeclarationJson, TypeDeclarationJson, VariableDeclarationJson, EnumDeclarationJson, ComponentDeclarationJson, SnippetDeclarationJson, NamespaceDeclarationJson. Each variant has only the fields relevant to that kind, enforced by z.strictObject. Use isKind (in declaration-helpers.ts) to narrow.

MemberJson is similarly a z.discriminatedUnion on kind with 3 variants: FunctionMemberJson, VariableMemberJson, ConstructorMemberJson. Each variant has only the fields relevant to that member kind.

Internal analysis code that constructs declarations incrementally uses DeclarationJsonBuild — a permissive interface with all fields optional. Zod validation at the ModuleJson.parse() boundary enforces variant correctness.

@see declaration-helpers.ts for display formatting and type narrowing utilities @see analyze.ts for the main analysis entry points @see tsdoc.ts for JSDoc/TSDoc extraction into these types @see postprocess.ts for post-processing (mergeReExports, findDuplicates)

Declarations
#

29 declarations

view source

ClassDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"class">; extends: ZodOptional<ZodString>; implements: ZodDefault<ZodArray<ZodString>>; ... 15 more ...; genericParams: ZodDefault<...>; }, $strict>

A class declaration. Has members, extends, implements.

ComponentDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"component">; intersects: ZodDefault<ZodArray<ZodString>>; props: ZodDefault<ZodArray<ZodObject<{ examples: ZodDefault<ZodArray<ZodString>>; ... 10 more ...; parameters: ZodOptional<...>; }, $strict>>>; ... 16 more ...; genericParams: ZodDefault<...>; }, $strict>

A Svelte component declaration. Has props, intersects, acceptsChildren.

ComponentPropJson
#

types.ts view source

ZodObject<{ examples: ZodDefault<ZodArray<ZodString>>; deprecatedMessage: ZodOptional<ZodString>; seeAlso: ZodDefault<ZodArray<ZodString>>; ... 8 more ...; parameters: ZodOptional<...>; }, $strict>

Component prop information for Svelte components.

Standalone schema (not extending ParameterJson) because component props have different semantics: named attributes with no positional order (<Foo {a} {b} /> = <Foo {b} {a} />), no rest parameters, and support for two-way binding via $bindable rune.

ComponentPropJsonInput
#

types.ts view source

{ name: string; type: string; examples?: string[] | undefined; deprecatedMessage?: string | undefined; seeAlso?: string[] | undefined; throws?: { description: string; type?: string | undefined; }[] | undefined; ... 5 more ...; parameters?: { ...; }[] | undefined; }

ConstructorMemberJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"constructor">; name: ZodUnion<readonly [ZodLiteral<"constructor">, ZodLiteral<"(construct)">]>; parameters: ZodDefault<ZodArray<ZodObject<...>>>; ... 12 more ...; genericParams: ZodDefault<...>; }, $strict>

A constructor member (class constructor, construct signature). Has parameters, overloads — but not returnType/returnDescription (constructors always return their class).

name is narrowed to two literal sentinels: 'constructor' for class constructors and '(construct)' for interface/type-alias construct signatures (which share kind: 'constructor' but originate from getConstructSignatures() on a non-class type — no user-chosen identifier exists). The literal is preserved (rather than omitted) so getDisplayName and consumer renderers reading member.name keep working without a constructor-specific branch.

DeclarationJson
#

types.ts view source

ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; returnType: ZodOptional<ZodString>; returnDescription: ZodOptional<ZodString>; ... 16 more ...; genericParams: ZodDefault<...>; }, $strict>, ... 7 more ..., ZodObject<...>], "kind">

Metadata for an exported declaration (function, type, class, component, etc.).

Discriminated union on kind — each variant has only the fields relevant to that kind. Use isKind (in declaration-helpers.ts) to narrow, or check declaration.kind directly.

DeclarationJsonInput
#

types.ts view source

{ kind: "function"; name: string; returnType?: string | undefined; returnDescription?: string | undefined; parameters?: { name: string; type: string; optional?: boolean | undefined; rest?: boolean | undefined; description?: string | undefined; defaultValue?: string | undefined; }[] | undefined; ... 14 more ...; gene...

DeclarationKind
#

types.ts view source

ZodEnum<{ function: "function"; type: "type"; variable: "variable"; class: "class"; interface: "interface"; enum: "enum"; component: "component"; snippet: "snippet"; namespace: "namespace"; }>

The kind of top-level exported declaration.

Does not include 'constructor' — constructors only appear as MemberKind (nested in classes, interfaces, or types with construct signatures), never as top-level module exports.

DeclarationModifier
#

types.ts view source

ZodEnum<{ public: "public"; protected: "protected"; readonly: "readonly"; static: "static"; abstract: "abstract"; getter: "getter"; setter: "setter"; }>

TypeScript modifier keywords extracted from declarations.

Only modifiers that appear on public API members are included. Private members (including #field syntax) are filtered out during analysis. Protected members are included as part of the extension API.

EnumDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"enum">; members: ZodDefault<ZodArray<ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; name: ZodString; optional: ZodDefault<ZodBoolean>; ... 15 more ...; genericParams: ZodDefault<...>; }, $strict>, ZodObject<...>, ZodObject<...>], "kind">>>; ... 14 more ...; genericPara...

An enum declaration. Has members for enum values.

FunctionDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"function">; returnType: ZodOptional<ZodString>; returnDescription: ZodOptional<ZodString>; ... 16 more ...; genericParams: ZodDefault<...>; }, $strict>

A function declaration. Has parameters, returnType, returnDescription, overloads.

FunctionMemberJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"function">; name: ZodString; optional: ZodDefault<ZodBoolean>; returnType: ZodOptional<ZodString>; ... 14 more ...; genericParams: ZodDefault<...>; }, $strict>

A function member (method, call signature, method signature). Has parameters, returnType, returnDescription, overloads.

optional reflects a ? token on the declaration (e.g., foo?(): void on an interface or type literal). Always false for index/call/construct signatures and for class methods (TypeScript disallows optional methods on classes).

name is the user-chosen method/property identifier, except for call signatures on interfaces and type aliases where it is the literal sentinel '(call)'.

GenericParamJson
#

types.ts view source

ZodObject<{ name: ZodString; constraint: ZodOptional<ZodString>; defaultType: ZodOptional<ZodString>; }, $strict>

Generic type parameter metadata extracted from declarations like <T extends string = unknown>.

Present on functions, classes, interfaces, type aliases, and Svelte components that declare generic type parameters.

InterfaceDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"interface">; extends: ZodDefault<ZodArray<ZodString>>; members: ZodDefault<ZodArray<ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; ... 17 more ...; genericParams: ZodDefault<...>; }, $strict>, ZodObject<...>, ZodObject<...>], "kind">>>; ... 14 more ...; genericParams: ...

An interface declaration. Has members, extends.

MemberJson
#

types.ts view source

ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; name: ZodString; optional: ZodDefault<ZodBoolean>; returnType: ZodOptional<ZodString>; ... 14 more ...; genericParams: ZodDefault<...>; }, $strict>, ZodObject<...>, ZodObject<...>], "kind">

Metadata for a nested declaration within a class, interface, type, or enum.

Discriminated union on kind with 3 variants: FunctionMemberJson, VariableMemberJson, ConstructorMemberJson. Use isKind (in declaration-helpers.ts) to narrow, or check member.kind directly.

Does not include fields that exist on declarations but not on members (extends, intersects, implements, props, alsoExportedFrom, aliasOf).

Nesting is exactly one level deep — members never contain their own members.

MemberJsonInput
#

types.ts view source

{ kind: "function"; name: string; optional?: boolean | undefined; returnType?: string | undefined; returnDescription?: string | undefined; parameters?: { name: string; type: string; optional?: boolean | undefined; rest?: boolean | undefined; description?: string | undefined; defaultValue?: string | undefined; }[] | ...

MemberKind
#

types.ts view source

ZodEnum<{ function: "function"; variable: "variable"; constructor: "constructor"; }>

The subset of declaration kinds that appear as nested members in classes, interfaces, and types.

Class members include constructors ('constructor'), methods ('function'), and properties/accessors ('variable'). Interface/type properties use the same kinds for property signatures, method signatures, index signatures, and call/construct signatures.

Top-level-only kinds ('class', 'interface', 'type', 'enum', 'component') never appear as members — nesting is exactly one level deep.

ModuleJson
#

types.ts view source

ZodObject<{ path: ZodString; declarations: ZodDefault<ZodArray<ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; returnType: ZodOptional<ZodString>; returnDescription: ZodOptional<...>; ... 16 more ...; genericParams: ZodDefault<...>; }, $strict>, ... 7 more ..., ZodObject<...>], "kind">>>; ... 4 more...

Metadata for a source module — the top-level container in the data model.

analyze and analyzeFromFiles return Array<ModuleJson> sorted alphabetically by path. Each module contains its exported declarations, dependency graph, and optional moduleComment.

ModuleJsonInput
#

types.ts view source

{ path: string; declarations?: ({ kind: "function"; name: string; returnType?: string | undefined; returnDescription?: string | undefined; parameters?: { name: string; type: string; optional?: boolean | undefined; rest?: boolean | undefined; description?: string | undefined; defaultValue?: string | undefined; }[] | ...

NamespaceDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"namespace">; module: ZodString; alsoExportedFrom: ZodDefault<ZodArray<ZodString>>; aliasOf: ZodOptional<ZodObject<{ ...; }, $strict>>; ... 12 more ...; genericParams: ZodDefault<...>; }, $strict>

A namespace re-export binding: export * as ns from './x'.

Carries no inline members — module points to the source module whose declarations are projected under this name. Consumers that want to render ns.a can deref by reading the source module's declarations array.

OverloadJson
#

types.ts view source

ZodObject<{ typeSignature: ZodString; parameters: ZodDefault<ZodArray<ZodObject<{ name: ZodString; type: ZodString; optional: ZodDefault<ZodBoolean>; rest: ZodDefault<...>; description: ZodOptional<...>; defaultValue: ZodOptional<...>; }, $strict>>>; returnType: ZodOptional<...>; genericParams: ZodDefault<...>; docC...

A single function overload signature.

When a function has multiple overload signatures, each public overload is captured here. The implementation signature is excluded.

OverloadJsonInput
#

types.ts view source

{ typeSignature: string; parameters?: { name: string; type: string; optional?: boolean | undefined; rest?: boolean | undefined; description?: string | undefined; defaultValue?: string | undefined; }[] | undefined; returnType?: string | undefined; genericParams?: { ...; }[] | undefined; docComment?: string | undefine...

ParameterJson
#

types.ts view source

ZodObject<{ name: ZodString; type: ZodString; optional: ZodDefault<ZodBoolean>; rest: ZodDefault<ZodBoolean>; description: ZodOptional<...>; defaultValue: ZodOptional<...>; }, $strict>

Parameter information for functions and methods.

Kept distinct from ComponentPropJson despite structural similarity. Function parameters form a tuple with positional semantics: calling order matters (fn(a, b) vs fn(b, a)), may include rest parameters and destructuring patterns.

ParameterJsonInput
#

types.ts view source

{ name: string; type: string; optional?: boolean | undefined; rest?: boolean | undefined; description?: string | undefined; defaultValue?: string | undefined; }

Reactivity
#

types.ts view source

ZodEnum<{ $state: "$state"; "$state.raw": "$state.raw"; $derived: "$derived"; "$derived.by": "$derived.by"; }>

Reactivity flavor for a variable declaration or class field, captured from the rune call at the initializer (e.g., let count = $state(0)).

Only the value-producing reactivity runes are represented here — $props and $bindable are modeled separately as ComponentPropJson.bindable (and prop-presence on the props array). A renderer wanting "all rune annotations across declarations and props" needs to read both this field and ComponentPropJson.bindable.

- $state — deeply reactive proxy - $state.raw — reference-only reactive (no proxy) - $derived — recomputed from dependencies (re-assignable) - $derived.by — same as $derived, with a function argument

Detection is syntactic (AST-based) and runs on every analyzed file regardless of extension. Most reactive declarations live in .svelte, .svelte.ts, or .svelte.js, but the field will also surface on any .ts/.js file that uses the same rune call patterns — by design, so documentation pipelines can capture any rune-shaped declaration their conventions choose to expose.

SnippetDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"snippet">; parameters: ZodDefault<ZodArray<ZodObject<{ name: ZodString; type: ZodString; optional: ZodDefault<ZodBoolean>; rest: ZodDefault<...>; description: ZodOptional<...>; defaultValue: ZodOptional<...>; }, $strict>>>; ... 14 more ...; genericParams: ZodDefault<...>; }, $strict>

A Svelte snippet declaration exported from <script module>. Has parameters.

TypeDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"type">; intersects: ZodDefault<ZodArray<ZodString>>; members: ZodDefault<ZodArray<ZodDiscriminatedUnion<[ZodObject<{ kind: ZodLiteral<"function">; ... 17 more ...; genericParams: ZodDefault<...>; }, $strict>, ZodObject<...>, ZodObject<...>], "kind">>>; ... 14 more ...; genericParams: Zo...

A type alias declaration. Has members, intersects.

VariableDeclarationJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"variable">; reactivity: ZodOptional<ZodEnum<{ $state: "$state"; "$state.raw": "$state.raw"; $derived: "$derived"; "$derived.by": "$derived.by"; }>>; ... 15 more ...; genericParams: ZodDefault<...>; }, $strict>

A variable declaration. Has optional reactivity for top-level rune-module exports (e.g., export let count = $state(0) in .svelte.ts or <script module>).

VariableMemberJson
#

types.ts view source

ZodObject<{ kind: ZodLiteral<"variable">; optional: ZodDefault<ZodBoolean>; reactivity: ZodOptional<ZodEnum<{ $state: "$state"; "$state.raw": "$state.raw"; $derived: "$derived"; "$derived.by": "$derived.by"; }>>; ... 13 more ...; genericParams: ZodDefault<...>; }, $strict>

A variable member (property, accessor, index signature, enum value). Shared fields plus optional reactivity for class fields initialized with a Svelte rune ($state, $state.raw, $derived, $derived.by).

optional reflects a ? token on the declaration (e.g., x?: string). Always false for index signatures and enum values.

Imported by
#