typescript-extract-type.ts

Per-declaration extractors for TypeScript type aliases, interfaces, and enums.

extractTypeInfo handles type aliases and interfaces (including index/method/ call/construct signatures and intersection filtering). extractEnumInfo handles regular and const enums. Both mutate a DeclarationJsonBuild with rich metadata derived from the TypeScript checker. Called by analyzeDeclaration in typescript-exports.ts once kind dispatch is settled.

Type-alias property walking (named properties, index/call/construct signatures) lives in typescript-extract-type-properties.ts to keep this module focused on top-level dispatch.

@see typescript-extract-shared.ts for shared helpers @see typescript-extract-type-properties.ts for type-alias property walking

view source

Declarations
#

2 declarations

extractEnumInfo
#

typescript-extract-type.ts view source

(node: Node, checker: TypeChecker, declaration: DeclarationJsonBuild, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 12 more ... | { ...; })[]): void import {extractEnumInfo} from 'svelte-docinfo/typescript-extract-type.js';

Extract enum member information from an enum declaration.

Iterates node.members to extract each enum member's name, initializer value, type, and JSDoc. Members are represented as MemberJson with kind 'variable'.

node

type Node

checker

type TypeChecker

declaration

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

mutates

  • declaration — adds members and typeSignature

extractTypeInfo
#

typescript-extract-type.ts view source

(node: Node, checker: TypeChecker, declaration: DeclarationJsonBuild, diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 12 more ... | { ...; })[], isExternalFile: IsExternalFile): void import {extractTypeInfo} from 'svelte-docinfo/typescript-extract-type.js';

Extract type/interface information with rich property metadata.

node

the declaration AST node

type Node

checker

TypeScript type checker

type TypeChecker

declaration

the declaration to populate

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

returns

void

mutates

  • declaration — adds typeSignature, genericParams, extends, intersects, members (and `partial: true` on extraction failure)
  • diagnostics — adds `type_extraction_failed` / `signature_analysis_failed` diagnostics on checker errors

Depends on
#

Imported by
#