typescript-exports.ts

Module-level export analysis: resolve every export of a TypeScript source file into a DeclarationAnalysis, including re-export classification.

Builds on the per-declaration extractors in typescript-extract-*.ts by adding the orchestration layer — alias chain walking, namespace classification, JSDoc routing for re-exports, default-slot handling.

@see typescript-program.ts for IsExternalFile and program construction @see typescript-extract-*.ts for the per-declaration extractors

view source

Declarations
#

5 declarations

analyzeDeclaration
#

typescript-exports.ts view source

(symbol: Symbol, sourceFile: SourceFile, ctx: ExtractContext): DeclarationAnalysis import {analyzeDeclaration} from 'svelte-docinfo/typescript-exports.js';

Analyze a TypeScript symbol and extract rich metadata.

This is a high-level function that combines TSDoc parsing with TypeScript type analysis to produce complete declaration metadata. Suitable for use in documentation generators, IDE integrations, and other tooling.

symbol

the TypeScript symbol to analyze

type Symbol

sourceFile

the source file containing the symbol

type SourceFile

ctx

the extraction pass's context (checker, diagnostics, externality predicate, alias registry)

returns

DeclarationAnalysis

complete declaration metadata including docs, types, and parameters, plus nodocs flag

analyzeExports
#

typescript-exports.ts view source

(sourceFile: SourceFile, ctx: ExtractContext, options: ModuleSourceOptions): ModuleExportsAnalysis import {analyzeExports} from 'svelte-docinfo/typescript-exports.js';

Analyze all exports from a TypeScript source file.

Extracts the module-level comment via extractModuleComment (skipped for svelte2tsx virtual files — see the inline note), star exports via extractStarExports, and all exported declarations with complete metadata. Handles re-exports by:

  • Same-name re-exports: tracked in reExports for alsoExportedFrom building
  • Renamed re-exports: included as new declarations with aliasOf metadata
  • Star exports (export * from): tracked in starExports for namespace-level info
  • Direct external re-exports: tracked in externalReExports/externalStarExports (specifier as written; import-then-export and source-chained forms stay silent)

This is a mid-level function (above the individual extract* helpers, below analyze) suitable for building documentation, API explorers, or analysis tools. For standard SvelteKit library layouts, use createSourceOptions(process.cwd()).

sourceFile

the TypeScript source file to analyze

type SourceFile

ctx

the extraction pass's context (see ExtractContext) — analyzeModule and analyzeSvelteModule construct it via createExtractContext; a direct caller owns the construction, deciding every field explicitly (tests use mockExtractContext). Its isExternalFile must be derived from the same options passed here: this function derives its own path-keyed twin (createIsExternalPath) from options, and the two externality axes are expected to agree

options

module source options for path extraction in re-exports

returns

ModuleExportsAnalysis

module comment, declarations, re-exports (source + external), and star exports (source + external)

analyzeTypescriptModule
#

typescript-exports.ts view source

(sourceFileInfo: SourceFileInfo & { dependents?: readonly string[] | undefined; }, tsSourceFile: SourceFile, modulePath: string, ctx: ExtractContext, options: ModuleSourceOptions): ModuleAnalysis import {analyzeTypescriptModule} from 'svelte-docinfo/typescript-exports.js';

Analyze a TypeScript file and extract module metadata.

Wraps analyzeExports and adds dependency information via extractDependencies from the source file info if available.

This is a high-level function suitable for building documentation or library metadata. For lower-level analysis, use analyzeExports directly.

sourceFileInfo

the source file info (from file system, build pipeline, or other source)

type SourceFileInfo & { dependents?: readonly string[] | undefined; }

tsSourceFile

TypeScript source file from the program

type SourceFile

modulePath

the module path (relative to source root)

type string

ctx

the extraction pass's context (see analyzeExports for the construction contract)

options

module source options for path extraction

returns

ModuleAnalysis

module metadata and re-export information

extractModuleComment
#

typescript-exports.ts view source

(sourceFile: SourceFile): string | undefined import {extractModuleComment} from 'svelte-docinfo/typescript-exports.js';

Extract module-level comment.

sourceFile

type SourceFile

returns

string | undefined

cleaned module comment text (with @module line removed), or undefined if no @module comment found

see also

warnModuleCommentNodocs
#

typescript-exports.ts view source

(moduleComment: string | undefined, diagnosticFile: string, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 14 more ... | { ...; })[]): void import {warnModuleCommentNodocs} from 'svelte-docinfo/typescript-exports.js';

Warn when a module comment carries @nodocs.

The tag has no module-level meaning — it applies to declarations and export statements — so its presence in a @module comment is always author confusion: it does nothing except remain verbatim in moduleComment text. Same line-start detection as extractModuleComment's @module test, so a backticked or mid-prose mention doesn't trigger.

moduleComment

type string | undefined

diagnosticFile

absolute source id, the form normalizeDiagnosticPaths rewrites to the project-root-relative Diagnostic.file contract. Not a module path — those are relative to sourceRoot, and normalization passes an already-relative path through untouched, so a module path here ships as a second base for the same file.

type string

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

returns

void

Depends on
#

Imported by
#