OpenForm
CLICommands

generate

Last updated on

Generate TypeScript types for artifacts

Generate TypeScript types for an artifact file.

Usage

ofm generate <file> [options]

Arguments

ArgumentDescription
filePath to artifact file (JSON or YAML)

Options

OptionDescription
--output <format>Output format: typed (.d.ts) or ts (TypeScript module). Default: typed

Description

Reads an artifact file and generates TypeScript type declarations for it. This enables type-safe imports in your application code.

Two output formats are available:

  • typed (default) - Generates a .d.ts declaration file alongside the JSON artifact. If the input is YAML, a JSON copy is also generated.
  • ts - Generates a standalone TypeScript module with the artifact embedded as as const, preserving full literal types.

Examples

Generate .d.ts from JSON:

ofm generate artifacts/w9-form.json

Generate .d.ts from YAML:

ofm generate artifacts/lease.yaml

Generate TypeScript module:

ofm generate artifacts/w9-form.json --output ts

Output

For typed output:

✓ Generated: artifacts/w9-form.json.d.ts

You can now import the artifact with full type safety:
  import schema from './w9-form.json'
  import { open } from '@open-form/sdk'
  const w9Form = open.form(schema)

For ts output:

✓ Generated: artifacts/w9-form.ts

You can now import the artifact with full type safety:
  import { w9Form } from './w9-form.js'

See also

  • add - Add artifacts from a registry (supports --output typed and --output ts)
  • validate - Validate artifact schemas

On this page