CLICommands
generateLast updated on
Last updated on
Generate TypeScript types for artifacts
Generate TypeScript types for an artifact file.
Usage
ofm generate <file> [options]Arguments
| Argument | Description |
|---|---|
file | Path to artifact file (JSON or YAML) |
Options
| Option | Description |
|---|---|
--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.tsdeclaration 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.jsonGenerate .d.ts from YAML:
ofm generate artifacts/lease.yamlGenerate TypeScript module:
ofm generate artifacts/w9-form.json --output tsOutput
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'