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, checker: TypeChecker, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 12 more ... | { ...; })[], isExternalFile: IsExternalFile): 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

checker

the TypeScript type checker

type TypeChecker

diagnostics

diagnostics collector for non-fatal issues

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; } | ... 11 more ... | { ...; })[]

isExternalFile

predicate for determining whether a source file is external to the project

returns

DeclarationAnalysis

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

analyzeExports
#

typescript-exports.ts view source

(sourceFile: SourceFile, checker: TypeChecker, options: ModuleSourceOptions, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 12 more ... | { ...; })[]): 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

checker

the TypeScript type checker

type TypeChecker

options

module source options for path extraction in re-exports

diagnostics

diagnostics collector for non-fatal issues

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; } | ... 11 more ... | { ...; })[]

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, checker: TypeChecker, options: ModuleSourceOptions, diagnostics: ({ ...; } | ... 12 more ... | { ...; })[]): 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

checker

TypeScript type checker

type TypeChecker

options

module source options for path extraction

diagnostics

diagnostics collector for non-fatal issues

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; } | ... 11 more ... | { ...; })[]

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, file: string, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 12 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

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; } | ... 11 more ... | { ...; })[]

returns

void

Depends on
#

Imported by
#