UNPKG

builddocs

Version:

Generate HTML documentation from TypeScript types and doc comments

512 lines (506 loc) 42.3 kB
# Builddocs This is a utility that transforms code documented in a certain style into HTML. It is licensed under an MIT license. ## Interface <pre class="refcode"><a href="#buildDocs" class="def" id="buildDocs">buildDocs</a>(<a href="#buildDocs.conf" class="def" id="buildDocs.conf">conf</a>: <a href="#BuildConfig" class="ref">BuildConfig</a>): <a href="#ModuleDocs" class="ref">ModuleDocs</a>[] </pre> <div class="doc indent1"> Build the documentation for the given set of modules.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#BuildConfig" class="def" id="BuildConfig">BuildConfig</a> = { <a href="#BuildConfig.modules" class="def" id="BuildConfig.modules">modules</a>: <span class="keyword">readonly</span> ({ <a href="#BuildConfig.modules.filename" class="def" id="BuildConfig.modules.filename">filename</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#BuildConfig.modules.modname" class="def" id="BuildConfig.modules.modname">modname</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } | <a href="#Module" class="ref">Module</a>)[], <a href="#BuildConfig.renderMarkdown" class="def" id="BuildConfig.renderMarkdown">renderMarkdown</a>: (<a href="#BuildConfig.renderMarkdown.markdown" class="def" id="BuildConfig.renderMarkdown.markdown">markdown</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>) => <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#BuildConfig.maxCol" class="def" id="BuildConfig.maxCol">maxCol</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a href="#BuildConfig.resolveType" class="def" id="BuildConfig.resolveType">resolveType</a>?: (<a class="ref" href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type">Record</a>&lt;<a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | ((<a href="#BuildConfig.resolveType.type" class="def" id="BuildConfig.resolveType.type">type</a>: <a href="#Type.Reference" class="ref">Type.Reference</a>) => <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a>))[] } </pre> <pre class="refcode"><span class="keyword">type</span> <a href="#ModuleDocs" class="def" id="ModuleDocs">ModuleDocs</a> = { <a href="#ModuleDocs.modname" class="def" id="ModuleDocs.modname">modname</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#ModuleDocs.filename" class="def" id="ModuleDocs.filename">filename</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#ModuleDocs.module" class="def" id="ModuleDocs.module">module</a>: <a href="#Module" class="ref">Module</a>, <a href="#ModuleDocs.text" class="def" id="ModuleDocs.text">text</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#ModuleDocs.mainFile" class="def" id="ModuleDocs.mainFile">mainFile</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } </pre> <section class=class> <pre class="refcode"><span class="keyword">class</span> <a href="#BuildError" class="def heading" id="BuildError">BuildError</a> <span class="keyword">extends</span> <a class="ref" href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error">Error</a> { </pre> <pre class="refcode">} </pre> </section> <pre class="refcode"><a href="#resolveLink" class="def" id="resolveLink">resolveLink</a>( <a href="#resolveLink.project" class="def" id="resolveLink.project">project</a>: <span class="keyword">readonly</span> <a href="#Module" class="ref">Module</a>[], <a href="#resolveLink.path" class="def" id="resolveLink.path">path</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#resolveLink.homemod" class="def" id="resolveLink.homemod">homemod</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> ): { <a href="#resolveLink.returns.id" class="def" id="resolveLink.returns.id">id</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#resolveLink.returns.name" class="def" id="resolveLink.returns.name">name</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } | <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a> </pre> <div class="doc indent1"> Try to resolve a `@link`-style path into the given project.</div> <pre class="refcode"><a href="#resolveLinks" class="def" id="resolveLinks">resolveLinks</a>( <a href="#resolveLinks.project" class="def" id="resolveLinks.project">project</a>: <span class="keyword">readonly</span> <a href="#Module" class="ref">Module</a>[], <a href="#resolveLinks.text" class="def" id="resolveLinks.text">text</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#resolveLinks.config" class="def" id="resolveLinks.config">config</a>: { <a href="#resolveLinks.config.homemod" class="def" id="resolveLinks.config.homemod">homemod</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#resolveLinks.config.warn" class="def" id="resolveLinks.config.warn">warn</a>?: (<a href="#resolveLinks.config.warn.target" class="def" id="resolveLinks.config.warn.target">target</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>) => <span class="keyword">void</span>, <a href="#resolveLinks.config.prefix" class="def" id="resolveLinks.config.prefix">prefix</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } = {} ): <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent1"> Find and resolve all `@link` references in the given Markdown string. Will call `warn` when running into an unresolved link.</div> <pre class="refcode"><a href="#getDocs" class="def" id="getDocs">getDocs</a>(<a href="#getDocs.spec" class="def" id="getDocs.spec">spec</a>: { </pre> <pre class="refcode"> <a href="#getDocs.spec.modules" class="def" id="getDocs.spec.modules">modules</a>: <span class="keyword">readonly</span> {<a href="#getDocs.spec.modules.filename" class="def" id="getDocs.spec.modules.filename">filename</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#getDocs.spec.modules.modname" class="def" id="getDocs.spec.modules.modname">modname</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}[] </pre> <div class="doc indent2"> The modules to use as entry points. If a `modname` is given, it will be prefixed to any IDs generated for bindings in the module.</div> <pre class="refcode"> <a href="#getDocs.spec.basedir" class="def" id="getDocs.spec.basedir">basedir</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> A base directory. Paths included in the output will be relative to this. Will default to the directory holding tsconfig.json or, failing that, the directory of the first module.</div> <pre class="refcode">}): <span class="keyword">readonly</span> <a href="#Module" class="ref">Module</a>[] </pre> <div class="doc indent1"> Gather the types and documentation for the given modules.</div> <section class=interface> <pre class="refcode"><span class="keyword">interface</span> <a href="#Module" class="def heading" id="Module">Module</a> { </pre> <div class="doc indent1"> Output format for a module.</div> <pre class="refcode"> <a href="#Module.filename" class="def" id="Module.filename">filename</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <pre class="refcode"> <a href="#Module.modname" class="def" id="Module.modname">modname</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <pre class="refcode"> <a href="#Module.items" class="def" id="Module.items">items</a>: <span class="keyword">readonly</span> <a href="#Item" class="ref">Item</a>[] </pre> <pre class="refcode"> <a href="#Module.template" class="def" id="Module.template">template</a>: <span class="keyword">readonly</span> (<a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | {<a href="#Module.template.export" class="def" id="Module.template.export">export</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>})[] </pre> <pre class="refcode">} </pre> </section> <section class=interface> <pre class="refcode"><span class="keyword">interface</span> <a href="#Binding" class="def heading" id="Binding">Binding</a> { </pre> <div class="doc indent1"> A binding is any export, member, parameter, or enum member.</div> <pre class="refcode"> <a href="#Binding.name" class="def" id="Binding.name">name</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> The name of the binding. For destructuring parameters this will be the empty string.</div> <pre class="refcode"> <a href="#Binding.qualifiedName" class="def" id="Binding.qualifiedName">qualifiedName</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> For static fields, namespace exports, or enum members, this holds their name prefixed by their namespace scope.</div> <pre class="refcode"> <a href="#Binding.id" class="def" id="Binding.id">id</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> Every binding gets a unique ID. This will generally be the path to the binding (including the mod name, if any), but when those are not unique, it may have a suffix like `_2` added.</div> <pre class="refcode"> <a href="#Binding.description" class="def" id="Binding.description">description</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> The doc comment above the binding.</div> <pre class="refcode"> <a href="#Binding.loc" class="def" id="Binding.loc">loc</a>?: {<a href="#Binding.loc.file" class="def" id="Binding.loc.file">file</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#Binding.loc.line" class="def" id="Binding.loc.line">line</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, <a href="#Binding.loc.column" class="def" id="Binding.loc.column">column</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>} </pre> <div class="doc indent2"> The source location of the binding, if available.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Item" class="def" id="Item">Item</a> = <a href="#Item.Class" class="ref">Item.Class</a> | <a href="#Item.Enum" class="ref">Item.Enum</a> | <a href="#Item.EnumMember" class="ref">Item.EnumMember</a> | <a href="#Item.Interface" class="ref">Item.Interface</a> | <a href="#Item.Variable" class="ref">Item.Variable</a> | <a href="#Item.TypeAlias" class="ref">Item.TypeAlias</a> | <a href="#Item.Function" class="ref">Item.Function</a> | <a href="#Item.Export" class="ref">Item.Export</a> | <a href="#Item.Namespace" class="ref">Item.Namespace</a> </pre> <div class="doc indent1"> Items are top-level or namespaced exports. They are subtype of [`Binding`](#Binding) and [`Type`](#Type) (sometimes a specific type), and form a tagged union through their `kind` property.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Class" class="def" id="Item.Class">Item.Class</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Class" class="ref">Type.Class</a> &amp; { <a href="#Item.Class.kind" class="def" id="Item.Class.kind">kind</a>: <span class="literal">&quot;class&quot;</span>, <a href="#Item.Class.abstract" class="def" id="Item.Class.abstract">abstract</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Item.Class.typeParams" class="def" id="Item.Class.typeParams">typeParams</a>?: <span class="keyword">readonly</span> <a href="#TypeParam" class="ref">TypeParam</a>[] } </pre> <div class="doc indent1"> A class item.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Enum" class="def" id="Item.Enum">Item.Enum</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Enum" class="ref">Type.Enum</a> &amp; {<a href="#Item.Enum.kind" class="def" id="Item.Enum.kind">kind</a>: <span class="literal">&quot;enum&quot;</span>} </pre> <div class="doc indent1"> Item for an enum. The enum type will hold the members.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.EnumMember" class="def" id="Item.EnumMember">Item.EnumMember</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type" class="ref">Type</a> &amp; {<a href="#Item.EnumMember.kind" class="def" id="Item.EnumMember.kind">kind</a>: <span class="literal">&quot;enummember&quot;</span>} </pre> <div class="doc indent1"> Item for an enum member.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Interface" class="def" id="Item.Interface">Item.Interface</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Interface" class="ref">Type.Interface</a> &amp; { <a href="#Item.Interface.kind" class="def" id="Item.Interface.kind">kind</a>: <span class="literal">&quot;interface&quot;</span>, <a href="#Item.Interface.typeParams" class="def" id="Item.Interface.typeParams">typeParams</a>?: <span class="keyword">readonly</span> <a href="#TypeParam" class="ref">TypeParam</a>[] } </pre> <div class="doc indent1"> Interface item.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Variable" class="def" id="Item.Variable">Item.Variable</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type" class="ref">Type</a> &amp; { <a href="#Item.Variable.kind" class="def" id="Item.Variable.kind">kind</a>: <span class="literal">&quot;variable&quot;</span>, <a href="#Item.Variable.readonly" class="def" id="Item.Variable.readonly">readonly</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> } </pre> <div class="doc indent1"> Item for a variable export. `readonly` will be true for `const` declarations.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.TypeAlias" class="def" id="Item.TypeAlias">Item.TypeAlias</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type" class="ref">Type</a> &amp; { <a href="#Item.TypeAlias.kind" class="def" id="Item.TypeAlias.kind">kind</a>: <span class="literal">&quot;typealias&quot;</span>, <a href="#Item.TypeAlias.typeParams" class="def" id="Item.TypeAlias.typeParams">typeParams</a>?: <span class="keyword">readonly</span> <a href="#TypeParam" class="ref">TypeParam</a>[] } </pre> <div class="doc indent1"> Item type for a type declaration.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Function" class="def" id="Item.Function">Item.Function</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Function" class="ref">Type.Function</a> &amp; {<a href="#Item.Function.kind" class="def" id="Item.Function.kind">kind</a>: <span class="literal">&quot;function&quot;</span>} </pre> <div class="doc indent1"> Function declaration item.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Export" class="def" id="Item.Export">Item.Export</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Reference" class="ref">Type.Reference</a> &amp; {<a href="#Item.Export.kind" class="def" id="Item.Export.kind">kind</a>: <span class="literal">&quot;reexport&quot;</span>} </pre> <div class="doc indent1"> Item for an export that exports a binding import from another module.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Item.Namespace" class="def" id="Item.Namespace">Item.Namespace</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Namespace" class="ref">Type.Namespace</a> &amp; {<a href="#Item.Namespace.kind" class="def" id="Item.Namespace.kind">kind</a>: <span class="literal">&quot;namespace&quot;</span>} </pre> <div class="doc indent1"> Item for a namespace.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Member" class="def" id="Member">Member</a> = <a href="#Member.Property" class="ref">Member.Property</a> | <a href="#Member.Method" class="ref">Member.Method</a> | <a href="#Member.Constructor" class="ref">Member.Constructor</a> </pre> <div class="doc indent1"> Classes, objects, and interfaces contain a number of member bindings.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Member.Property" class="def" id="Member.Property">Member.Property</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type" class="ref">Type</a> &amp; { <a href="#Member.Property.kind" class="def" id="Member.Property.kind">kind</a>: <span class="literal">&quot;property&quot;</span>, <a href="#Member.Property.abstract" class="def" id="Member.Property.abstract">abstract</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Property.protected" class="def" id="Member.Property.protected">protected</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Property.readonly" class="def" id="Member.Property.readonly">readonly</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Property.static" class="def" id="Member.Property.static">static</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Property.optional" class="def" id="Member.Property.optional">optional</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> } </pre> <div class="doc indent1"> Property member.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Member.Method" class="def" id="Member.Method">Member.Method</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Function" class="ref">Type.Function</a> &amp; { <a href="#Member.Method.kind" class="def" id="Member.Method.kind">kind</a>: <span class="literal">&quot;method&quot;</span>, <a href="#Member.Method.abstract" class="def" id="Member.Method.abstract">abstract</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Method.protected" class="def" id="Member.Method.protected">protected</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Member.Method.static" class="def" id="Member.Method.static">static</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> } </pre> <div class="doc indent1"> Member for a methor.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Member.Constructor" class="def" id="Member.Constructor">Member.Constructor</a> = <a href="#Binding" class="ref">Binding</a> &amp; <a href="#Type.Function" class="ref">Type.Function</a> &amp; { <a href="#Member.Constructor.kind" class="def" id="Member.Constructor.kind">kind</a>: <span class="literal">&quot;constructor&quot;</span>, <a href="#Member.Constructor.protected" class="def" id="Member.Constructor.protected">protected</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> } </pre> <div class="doc indent1"> Member for a class constructor.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type" class="def" id="Type">Type</a> = <a href="#Type.Reference" class="ref">Type.Reference</a> | <a href="#Type.Class" class="ref">Type.Class</a> | <a href="#Type.Enum" class="ref">Type.Enum</a> | <a href="#Type.Simple" class="ref">Type.Simple</a> | <a href="#Type.Namespace" class="ref">Type.Namespace</a> | <a href="#Type.Literal" class="ref">Type.Literal</a> | <a href="#Type.Template" class="ref">Type.Template</a> | <a href="#Type.Union" class="ref">Type.Union</a> | <a href="#Type.Intersection" class="ref">Type.Intersection</a> | <a href="#Type.Indexed" class="ref">Type.Indexed</a> | <a href="#Type.KeyOf" class="ref">Type.KeyOf</a> | <a href="#Type.Object" class="ref">Type.Object</a> | <a href="#Type.Interface" class="ref">Type.Interface</a> | <a href="#Type.Function" class="ref">Type.Function</a> | <a href="#Type.Mapped" class="ref">Type.Mapped</a> | <a href="#Type.Inferred" class="ref">Type.Inferred</a> | <a href="#Type.Conditional" class="ref">Type.Conditional</a> | <a href="#Type.Tuple" class="ref">Type.Tuple</a> | <a href="#Type.Typeof" class="ref">Type.Typeof</a> | <a href="#Type.Predicate" class="ref">Type.Predicate</a> </pre> <div class="doc indent1"> The collection of types represented by the output.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.SimpleTag" class="def" id="Type.SimpleTag">Type.SimpleTag</a> = <span class="literal">&quot;string&quot;</span> | <span class="literal">&quot;number&quot;</span> | <span class="literal">&quot;bigint&quot;</span> | <span class="literal">&quot;boolean&quot;</span> | <span class="literal">&quot;symbol&quot;</span> | <span class="literal">&quot;undefined&quot;</span> | <span class="literal">&quot;any&quot;</span> | <span class="literal">&quot;null&quot;</span> | <span class="literal">&quot;void&quot;</span> | <span class="literal">&quot;never&quot;</span> | <span class="literal">&quot;unknown&quot;</span> </pre> <div class="doc indent1"> Simple types are tagged with one of these strings.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Simple" class="def" id="Type.Simple">Type.Simple</a> = {<a href="#Type.Simple.type" class="def" id="Type.Simple.type">type</a>: <span class="literal">&quot;simple&quot;</span>, <a href="#Type.Simple.typeName" class="def" id="Type.Simple.typeName">typeName</a>: <a href="#Type.SimpleTag" class="ref">Type.SimpleTag</a>} </pre> <div class="doc indent1"> Used for various kinds of atomic types.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Namespace" class="def" id="Type.Namespace">Type.Namespace</a> = {<a href="#Type.Namespace.type" class="def" id="Type.Namespace.type">type</a>: <span class="literal">&quot;namespace&quot;</span>, <a href="#Type.Namespace.items" class="def" id="Type.Namespace.items">items</a>: <span class="keyword">readonly</span> <a href="#Item" class="ref">Item</a>[]} </pre> <div class="doc indent1"> Only used in [`Item.Namespace`](#Item.Namespace). Holds the namespace's items.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Reference" class="def heading" id="Type.Reference">Type.Reference</a> = { </pre> <div class="doc indent1"> A reference to a type defined elsewhere.</div> <pre class="refcode"> <a href="#Type.Reference.type" class="def" id="Type.Reference.type">type</a>: <span class="literal">&quot;reference&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Reference.typeName" class="def" id="Type.Reference.typeName">typeName</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> The (possibly qualified) name of the referenced type.</div> <pre class="refcode"> <a href="#Type.Reference.local" class="def" id="Type.Reference.local">local</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> If the type is part of the project, this holds its ID.</div> <pre class="refcode"> <a href="#Type.Reference.source" class="def" id="Type.Reference.source">source</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> </pre> <div class="doc indent2"> The source file that defines the referenced type. Will be missing for built-in types.</div> <pre class="refcode"> <a href="#Type.Reference.typeArgs" class="def" id="Type.Reference.typeArgs">typeArgs</a>?: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] </pre> <div class="doc indent2"> The type arguments given to the type, if any.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Enum" class="def" id="Type.Enum">Type.Enum</a> = { <a href="#Type.Enum.type" class="def" id="Type.Enum.type">type</a>: <span class="literal">&quot;enum&quot;</span>, <a href="#Type.Enum.items" class="def" id="Type.Enum.items">items</a>: <span class="keyword">readonly</span> <a href="#Item.EnumMember" class="ref">Item.EnumMember</a>[] } </pre> <div class="doc indent1"> Only used in [`Item.Enum`](#Item.Enum).</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Template" class="def" id="Type.Template">Type.Template</a> = { <a href="#Type.Template.type" class="def" id="Type.Template.type">type</a>: <span class="literal">&quot;template&quot;</span>, <a href="#Type.Template.typeArgs" class="def" id="Type.Template.typeArgs">typeArgs</a>: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] } </pre> <div class="doc indent1"> A template string type. The type args hold the types for the slots.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Literal" class="def" id="Type.Literal">Type.Literal</a> = { <a href="#Type.Literal.type" class="def" id="Type.Literal.type">type</a>: <span class="literal">&quot;literal&quot;</span>, <a href="#Type.Literal.value" class="def" id="Type.Literal.value">value</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a> | <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> } </pre> <div class="doc indent1"> A literal type.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Union" class="def heading" id="Type.Union">Type.Union</a> = { </pre> <div class="doc indent1"> A union.</div> <pre class="refcode"> <a href="#Type.Union.type" class="def" id="Type.Union.type">type</a>: <span class="literal">&quot;union&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Union.typeArgs" class="def" id="Type.Union.typeArgs">typeArgs</a>: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] </pre> <div class="doc indent2"> The types in the union.</div> <pre class="refcode">} </pre> </section> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Intersection" class="def heading" id="Type.Intersection">Type.Intersection</a> = { </pre> <div class="doc indent1"> An intersection type.</div> <pre class="refcode"> <a href="#Type.Intersection.type" class="def" id="Type.Intersection.type">type</a>: <span class="literal">&quot;intersection&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Intersection.typeArgs" class="def" id="Type.Intersection.typeArgs">typeArgs</a>: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] </pre> <div class="doc indent2"> The set of intersected types.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.KeyOf" class="def" id="Type.KeyOf">Type.KeyOf</a> = {<a href="#Type.KeyOf.type" class="def" id="Type.KeyOf.type">type</a>: <span class="literal">&quot;keyof&quot;</span>, <a href="#Type.KeyOf.inner" class="def" id="Type.KeyOf.inner">inner</a>: <a href="#Type" class="ref">Type</a>} </pre> <div class="doc indent1"> Used for `keyof T` types.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Object" class="def heading" id="Type.Object">Type.Object</a> = { </pre> <div class="doc indent1"> Type of object that's not a plain function, class instance, on interface.</div> <pre class="refcode"> <a href="#Type.Object.type" class="def" id="Type.Object.type">type</a>: <span class="literal">&quot;object&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Object.members" class="def" id="Type.Object.members">members</a>: <span class="keyword">readonly</span> <a href="#Member" class="ref">Member</a>[] </pre> <div class="doc indent2"> The object's members.</div> <pre class="refcode"> <a href="#Type.Object.signatures" class="def" id="Type.Object.signatures">signatures</a>?: <span class="keyword">readonly</span> <a href="#CallSignature" class="ref">CallSignature</a>[] </pre> <div class="doc indent2"> Call signatures associated with the object.</div> <pre class="refcode">} </pre> </section> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Interface" class="def heading" id="Type.Interface">Type.Interface</a> = { </pre> <div class="doc indent1"> A type declared as an interface.</div> <pre class="refcode"> <a href="#Type.Interface.type" class="def" id="Type.Interface.type">type</a>: <span class="literal">&quot;interface&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Interface.members" class="def" id="Type.Interface.members">members</a>: <span class="keyword">readonly</span> <a href="#Member" class="ref">Member</a>[] </pre> <div class="doc indent2"> The interface's members.</div> <pre class="refcode"> <a href="#Type.Interface.signatures" class="def" id="Type.Interface.signatures">signatures</a>?: <span class="keyword">readonly</span> <a href="#CallSignature" class="ref">CallSignature</a>[] </pre> <div class="doc indent2"> Call signatures defined for the interface, if any.</div> <pre class="refcode"> <a href="#Type.Interface.implements" class="def" id="Type.Interface.implements">implements</a>?: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] </pre> <div class="doc indent2"> Super-interfaces, if any.</div> <pre class="refcode">} </pre> </section> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Class" class="def heading" id="Type.Class">Type.Class</a> = { </pre> <div class="doc indent1"> The type of a class.</div> <pre class="refcode"> <a href="#Type.Class.type" class="def" id="Type.Class.type">type</a>: <span class="literal">&quot;class&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Class.members" class="def" id="Type.Class.members">members</a>: <span class="keyword">readonly</span> <a href="#Member" class="ref">Member</a>[] </pre> <div class="doc indent2"> The class' members, both static an instance members. The two can be distinguished by their [`static`](#Member.Property) flag.</div> <pre class="refcode"> <a href="#Type.Class.extends" class="def" id="Type.Class.extends">extends</a>?: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> A superclass, if any.</div> <pre class="refcode"> <a href="#Type.Class.implements" class="def" id="Type.Class.implements">implements</a>?: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[] </pre> <div class="doc indent2"> Implemented interfaces.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Function" class="def" id="Type.Function">Type.Function</a> = { <a href="#Type.Function.type" class="def" id="Type.Function.type">type</a>: <span class="literal">&quot;function&quot;</span>, <a href="#Type.Function.signatures" class="def" id="Type.Function.signatures">signatures</a>: <span class="keyword">readonly</span> <a href="#CallSignature" class="ref">CallSignature</a>[] } </pre> <div class="doc indent1"> The type of a function.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Mapped" class="def heading" id="Type.Mapped">Type.Mapped</a> = { </pre> <div class="doc indent1"> A mapped type (`{[Prop in keyof T]: U[Prop]}`).</div> <pre class="refcode"> <a href="#Type.Mapped.type" class="def" id="Type.Mapped.type">type</a>: <span class="literal">&quot;mapped&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Mapped.key" class="def" id="Type.Mapped.key">key</a>: <a href="#TypeParam" class="ref">TypeParam</a> </pre> <div class="doc indent2"> The property name, which acts as a type parameter with its [`TypeParam.extends`](#TypeParam.extends) property referencing the type after the `in`.</div> <pre class="refcode"> <a href="#Type.Mapped.inner" class="def" id="Type.Mapped.inner">inner</a>: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The property value type.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Inferred" class="def" id="Type.Inferred">Type.Inferred</a> = {<a href="#Type.Inferred.type" class="def" id="Type.Inferred.type">type</a>: <span class="literal">&quot;infer&quot;</span>, <a href="#Type.Inferred.inner" class="def" id="Type.Inferred.inner">inner</a>: <a href="#Type" class="ref">Type</a>} </pre> <div class="doc indent1"> A type created with `infer T`.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Conditional" class="def heading" id="Type.Conditional">Type.Conditional</a> = { </pre> <div class="doc indent1"> A conditional type.</div> <pre class="refcode"> <a href="#Type.Conditional.type" class="def" id="Type.Conditional.type">type</a>: <span class="literal">&quot;conditional&quot;</span> </pre> <pre class="refcode"> <a href="#Type.Conditional.inner" class="def" id="Type.Conditional.inner">inner</a>: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The condition type.</div> <pre class="refcode"> <a href="#Type.Conditional.extends" class="def" id="Type.Conditional.extends">extends</a>?: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The type the condition type is checked against, if any.</div> <pre class="refcode"> <a href="#Type.Conditional.true" class="def" id="Type.Conditional.true">true</a>: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The type for when they match.</div> <pre class="refcode"> <a href="#Type.Conditional.false" class="def" id="Type.Conditional.false">false</a>: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The type for when they don't match.</div> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Tuple" class="def" id="Type.Tuple">Type.Tuple</a> = {<a href="#Type.Tuple.type" class="def" id="Type.Tuple.type">type</a>: <span class="literal">&quot;tuple&quot;</span>, <a href="#Type.Tuple.typeArgs" class="def" id="Type.Tuple.typeArgs">typeArgs</a>: <span class="keyword">readonly</span> <a href="#Type" class="ref">Type</a>[]} </pre> <div class="doc indent1"> A tuple type.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Typeof" class="def" id="Type.Typeof">Type.Typeof</a> = {<a href="#Type.Typeof.type" class="def" id="Type.Typeof.type">type</a>: <span class="literal">&quot;typeof&quot;</span>, <a href="#Type.Typeof.inner" class="def" id="Type.Typeof.inner">inner</a>: <a href="#Type" class="ref">Type</a>} </pre> <div class="doc indent1"> A type created with `typeof V`.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Indexed" class="def" id="Type.Indexed">Type.Indexed</a> = {<a href="#Type.Indexed.type" class="def" id="Type.Indexed.type">type</a>: <span class="literal">&quot;indexed&quot;</span>, <a href="#Type.Indexed.key" class="def" id="Type.Indexed.key">key</a>: <a href="#Type" class="ref">Type</a>, <a href="#Type.Indexed.inner" class="def" id="Type.Indexed.inner">inner</a>: <a href="#Type" class="ref">Type</a>} </pre> <div class="doc indent1"> A type for an indexed type like `T[K]`.</div> <pre class="refcode"><span class="keyword">type</span> <a href="#Type.Predicate" class="def" id="Type.Predicate">Type.Predicate</a> = { <a href="#Type.Predicate.type" class="def" id="Type.Predicate.type">type</a>: <span class="literal">&quot;predicate&quot;</span>, <a href="#Type.Predicate.inner" class="def" id="Type.Predicate.inner">inner</a>: <a href="#Type" class="ref">Type</a>, <a href="#Type.Predicate.target" class="def" id="Type.Predicate.target">target</a>: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } </pre> <div class="doc indent1"> The return type of a predicate (`: x is T`) function.</div> <section class=typealias> <pre class="refcode"><span class="keyword">type</span> <a href="#CallSignature" class="def heading" id="CallSignature">CallSignature</a> = { </pre> <div class="doc indent1"> Represents a function signature.</div> <pre class="refcode"> <a href="#CallSignature.type" class="def" id="CallSignature.type">type</a>: <span class="literal">&quot;function&quot;</span> | <span class="literal">&quot;method&quot;</span> | <span class="literal">&quot;constructor&quot;</span> </pre> <pre class="refcode"> <a href="#CallSignature.params" class="def" id="CallSignature.params">params</a>: <span class="keyword">readonly</span> <a href="#Param" class="ref">Param</a>[] </pre> <pre class="refcode"> <a href="#CallSignature.returns" class="def" id="CallSignature.returns">returns</a>?: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> Not set when the signature returns void or is a constructor.</div> <pre class="refcode"> <a href="#CallSignature.typeParams" class="def" id="CallSignature.typeParams">typeParams</a>?: <span class="keyword">readonly</span> <a href="#TypeParam" class="ref">TypeParam</a>[] </pre> <pre class="refcode">} </pre> </section> <pre class="refcode"><span class="keyword">type</span> <a href="#Param" class="def" id="Param">Param</a> = <a href="#Type" class="ref">Type</a> &amp; <a href="#Binding" class="ref">Binding</a> &amp; { <a href="#Param.kind" class="def" id="Param.kind">kind</a>: <span class="literal">&quot;param&quot;</span>, <a href="#Param.optional" class="def" id="Param.optional">optional</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Param.rest" class="def" id="Param.rest">rest</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, <a href="#Param.defaultValue" class="def" id="Param.defaultValue">defaultValue</a>?: <a class="prim" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> } </pre> <div class="doc indent1"> A function parameter.</div> <section class=interface> <pre class="refcode"><span class="keyword">interface</span> <a href="#TypeParam" class="def heading" id="TypeParam">TypeParam</a> <span class="keyword">extends</span> <a href="#Binding" class="ref">Binding</a> { </pre> <div class="doc indent1"> A type parameter.</div> <pre class="refcode"> <a href="#TypeParam.kind" class="def" id="TypeParam.kind">kind</a>: <span class="literal">&quot;typeparam&quot;</span> </pre> <pre class="refcode"> <a href="#TypeParam.default" class="def" id="TypeParam.default">default</a>?: <a href="#Type" class="ref">Type</a> </pre> <pre class="refcode"> <a href="#TypeParam.extends" class="def" id="TypeParam.extends">extends</a>?: <a href="#Type" class="ref">Type</a> </pre> <div class="doc indent2"> The type bound for this parameter.</div> <pre class="refcode">} </pre> </section>