TypescriptExtractorclass
new TypescriptExtractor()
| Return | |
|---|---|
TypescriptExtractor | File extractor that parses a TypeScript source file into a tree element. |
File extractor that parses a TypeScript source file into a tree element.
- Uses the TypeScript compiler API to parse the AST.
- Extracts exported, public, non-
_-prefixed declarations astree-documentationchildren. - Overloaded declarations sharing a name are merged into a single
tree-documentationwith multiplesignatures. When a function (or constructor) is overloaded, the implementation declaration (the "base definition") is dropped entirely — only the overload signatures are documented. - A
@param name {Type}(or@returns {Type}) whose{Type}is given is canonical: it supersedes the inferred type from the base definition and any overloads. Multiple@param nametags for one parameter each emit a row, letting a single parameter be documented as several typed variants. - Class declarations synthesise their
signatures,params, andreturnsfrom the constructor —new ClassName<…>(…)including generics, one signature per constructor overload, withreturnsset to the class type. Param descriptions come from the constructor's@paramfirst, then the class's@param. - A
@kindtag in a symbol's JSDoc overrides the inferred kind — e.g.@kind componentrelabels a React component (otherwise afunction) so the docs site groups and colours it as a component. The override also drops the trailing()from the title, since a non-function kind reads as a bare name. - Sets
description(a plain-text summary from the first JSDoc paragraph) on everytree-documentationchild. - Sets
titleon everytree-documentationchild —name()for functions,Class.name()for methods, barenamefor other kinds. (Data members are not child elements — seepropertiesbelow.) - Records relational metadata as raw strings for render-time linking:
class(owning class),readonly,extends/implements(full heritage type text including generic arguments, e.g.AbstractStore<string>orOmit<StringSchemaOptions, "value">), andtypes(the type names atypealias's body references, e.g.OtherTypeinstring | OtherType). - Records a structured
propertieslist for classes, interfaces, and object-literaltypealiases — each data member's (property/getter/setter) name, type, optionality, default, and description. This is the single source for a type's data members: they render as the type's Properties table and flatten into an options-bag parameter's fields at render time, rather than each becoming its own child element. Methods stay as child elements. - Names a destructured (binding-pattern) parameter for the Param column — which has no name of its own — from an explicit
@param, else its rest element (...options), else a type-derived fallback (props/options). The signature still shows the full{ … }. - Pretty-prints object-literal signatures (interfaces and object-literal
typealiases) as multi-line{ … }blocks, one member per line; other type bodies (string | null, mapped types, …) are emitted verbatim. - Members declared with the
overrideordeclaremodifier are skipped — the base class already documents overrides, anddeclaremembers are ambient type-only re-declarations rather than new API. - Keys are the raw declared
name(case-preserving) so case-distinct exports likeCollectionandCOLLECTIONstay separate. - The file element itself has no
title— a TS source file has no confident title source; renderers fall back toname.
Examples
const element = new TypescriptExtractor().extractProps("string.ts", sourceText);