re-exports #

A declaration is documented once, in the module that declares it, and re-exports point to it. An imported binding exported again (import {a} from './x'; export {a}, or export default of an import) counts as the export … from it stands for.

Encodings
#

  • Same name (export {a} from './x'): the declaration's alsoExportedFrom lists the re-exporting modules, and each of those lists the edge in ModuleJson.reExports ({name, module, typeOnly, sourceLine}), with module naming the declaring module through any chain.
  • Renamed (export {a as b} from './x'): a full declaration b in the re-exporting module, with aliasOf: {module, name: "a"} and the local specifier's sourceLine.
  • Star (export * from './x'): x's path in starExports, with no per-name entries. If x isn't documented itself, its names document in the re-exporting module instead.
  • Namespace (export * as ns from './x'): a kind: 'namespace' declaration whose module names x; read its members from that module.
  • Packages (export {a} from 'pkg', export * from 'pkg'): externalReExports and externalStarExports, with the specifier as written.

A re-export of a symbol from a module that isn't documented (like an internal/ one) is a full declaration with aliasOf, even under the same name, since there's no declaration to link to; its aliasOf.module names a module the output lacks. A re-export statement with its own JSDoc also gets a declaration of its own, its docs over the original's, and @nodocs on one drops it entirely.

A Svelte component svelte2tsx failed to transform re-exports as a partial component.

Default exports
#

export default and export {a as default} carry name: "default", except Svelte components, which take their filename's name. A rename out of the default slot (export {default as A} from './x') carries name: "A" and aliasOf: {module, name: "default"}, or the component's name for a Svelte component.

A module's full export surface
#

resolveExportSurface combines a module's declarations, re-exports, and stars with ES semantics: explicit exports shadow star names, names ambiguous between stars drop, and default never projects. It reports stars it can't see into rather than guessing.

import {resolveExportSurface} from 'svelte-docinfo/postprocess.js'; const surface = resolveExportSurface(modules, 'index.ts');

The output format examples include a barrel with a rename and a star.