svelte_helpers.ts

Declarations
#

Svelte component analysis helpers.

Extracts metadata from Svelte components using svelte2tsx transformations:

- Component props with types and JSDoc - Component-level documentation - Type information

Workflow: Transform Svelte to TypeScript via svelte2tsx, parse the transformed TypeScript with the TS Compiler API, extract component-level JSDoc from original source.

All functions are prefixed with svelte_ for clarity.

2 declarations

view source

svelte_analyze_component
#

svelte_helpers.ts view source

(ts_code: string, source_file: SourceFile, checker: TypeChecker, component_name: string): { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | ... 4 more ... | "css"; ... 19 more ...; alias_of?: { ...; } | undefined; }

Analyze a Svelte component from its svelte2tsx transformation.

ts_code

type string

source_file

type SourceFile

checker

type TypeChecker

component_name

type string

returns

{ [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; doc_comment?: string | undefined; type_signature?: string | undefined; ... 17 more ...; alias_of?: { ...; } | undefined; }

svelte_analyze_file
#

svelte_helpers.ts view source

(file_path: string, module_path: string, checker: TypeChecker): { [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; ... 19 more ...; alias_of?: { ...; } | undefined; }

Analyze a Svelte component file from disk.

This is a high-level function that handles the complete workflow: 1. Read the Svelte source from disk 2. Transform to TypeScript via svelte2tsx 3. Extract component metadata (props, documentation)

Suitable for use in documentation generators, build tools, and analysis.

file_path

Absolute path to the .svelte file

type string

module_path

Module path relative to src/lib (e.g., 'Alert.svelte')

type string

checker

TypeScript type checker for type resolution

type TypeChecker

returns

{ [x: string]: unknown; name: string; kind: "function" | "type" | "json" | "variable" | "class" | "constructor" | "component" | "css"; doc_comment?: string | undefined; type_signature?: string | undefined; ... 17 more ...; alias_of?: { ...; } | undefined; }

Complete declaration metadata for the component

Depends on
#

Imported by
#