Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Extern exports

Use xrf-cli externs export to generate or check a manifest of script exports declared through TypeScript extern(...) calls. Choose JSON for the tracked contract, XML for structured export, or HTML for a browsable reference.

Export a manifest

The examples below run from the xrf-engine repository root and require xrf-cli on your executable search path. For another declaration tree, replace src/engine/declarations with its root.

This command creates or replaces target/parsed/externs.html, creating parent directories when needed:

xrf-cli externs export src/engine/declarations `
  --format html `
  --output target/parsed/externs.html

Example output — export declarations:

Exported 3 externs to './extern.json'.

Exit code: 0.

Exit code 0 means the export succeeded. Open the resulting HTML file to browse namespaces and declarations. Manifest source paths are relative to the declarations root.

Formats

FormatArtifactDefault line endings
jsonManifest with an exports object.CRLF
xml<externs><exports> document.LF
htmlCollapsible namespace reference.LF

Writing with --output requires an explicit --format. Use --line-endings lf or --line-endings crlf to override the format’s default.

Check

Use --check to compare an existing artifact with the declarations without writing either. It cannot be combined with --output.

xrf-cli externs export src/engine/declarations `
  --check src/engine/declarations/extern.json

The check infers the format from the artifact’s extension unless --format is provided. JSON is compared as parsed manifest data; XML and HTML are compared as rendered text with line-ending differences ignored. This check does not enforce a line-ending policy.

Exit code 0 means the artifact matches. Exit code 3 indicates a mismatch or invalid declaration/artifact content; inspect the diagnostic before regenerating. An input that cannot be read is an execution failure, exit code 1. See CLI reporting and exit codes for the shared contract.

The engine wrapper for this check is npm run cli -- verify externs. It is available explicitly and is not a build or CI gate.

Requirements

Export names must be unique string literals. The parser reads supported function and value references from their declared TypeScript contracts; use an explicit value as Type assertion when a value needs its export type stated. Missing or unrenderable callable types are emitted as unknown. Unsupported declarations produce diagnostics rather than inferred runtime contracts.

The command skips *.test.ts, *.spec.ts, and sources under __test__.

Command reference

xrf-cli externs export

Export TypeScript extern declarations as JSON, XML, or HTML

xrf-cli externs export [OPTIONS] <declarations-root>
OptionRequiredDefaultDescription
<declarations-root>yesRoot directory containing TypeScript declaration sources
--format <format>Output format; required with –output and inferred from –check when omitted. Possible values: json, xml, html.
--output <output>Artifact to create or replace
--check <check>Existing artifact to verify without writing
--line-endings <line-endings>Override generated line endings. Possible values: lf, crlf.
-s, --silentTurn off logging
-v, --verboseTurn on verbose logging
--jsonWrite the run’s JSON report to stdout, moving human output to stderr
--report <PATH>Write the run’s JSON report to a file