Checks & Export
Function-level API for checking the build and getting data out of it. All of these wrap kicad-cli — they need a KiCAD installation (auto-detected on Windows, macOS, and
Linux, including Flatpak; KiCAD 10.0 supported).
runERC / runDRC
Electrical rule checks on the schematic and design rule checks on the board. Both return Promise<string> with the check output; design rules default to the JLCPCB no-surcharge standard written into the project.
Example first
import { runERC, runDRC } from '@typecad/pcb';
const erc = await runERC('./build/typecad.kicad_sch');
const drc = await runDRC('./build/typecad.kicad_pcb');
console.log(erc, drc);exportPCB / exportSchematic
Export the board or schematic to a file format — svg, pdf, and the other kicad-cli export formats.
Example first
import { exportPCB, exportSchematic } from '@typecad/pcb';
await exportPCB('./build/typecad.kicad_pcb', './build/typecad-top.svg', 'svg');
await exportSchematic('./build/typecad.kicad_sch', './build/typecad-sch.pdf', 'pdf');executeKiCADCommand / executeKiCADCommandSync
Run any kicad-cli command from TypeScript — the escape hatch the export functions are built on. Sync variant returns the string directly.
Example first
import { executeKiCADCommand } from '@typecad/pcb';
const version = await executeKiCADCommand('kicad-cli', ['version'], {});
console.log(version);All functions
| Function | Description |
|---|---|
| runERC(schPath, options) | Electrical rule checks on the schematic — Promise<string> |
| runDRC(pcbPath, options) | Design rule checks on the board — Promise<string> |
| exportPCB(pcbPath, outputPath, format, options?) | Export the board — svg, pdf, ... |
| exportSchematic(schPath, outputPath, format, options?) | Export the schematic — svg, pdf, ... |
| executeKiCADCommand(command, args, options) | Run any kicad-cli command — Promise<string> |
| executeKiCADCommandSync(command, args, options) | The synchronous form |
| upgradeFootprint(footprintPath, options) | Upgrade a footprint file to the current KiCAD version |
typecad.conf.ts
Projects are configured with a typecad.conf.ts file in the hw/ directory — build settings, KiCAD paths, and other options:
import { defineConfig } from '@typecad/pcb';
export default defineConfig({
entry: 'src/index.ts',
kicad_cli: '/usr/bin/kicad-cli',
kicad_path: '/usr/share/kicad',
use_flatpak: false,
verbose: false,
});| Option | Type | Description |
|---|---|---|
| entry | string | Path to the TypeScript entry file (relative to hw/) |
| kicad_cli | string | Path to the kicad-cli binary |
| kicad_path | string | Path to the KiCAD installation directory |
| use_flatpak | boolean | Prioritize a Flatpak installation |
| verbose | boolean | Verbose output during builds |
| rules | string | Path to a JSON design-constraints file (board rules, net classes, net assignments, DRC severities), relative to this conf file |
Run typecad-pcb doctor to verify the environment — it checks KiCAD, Node.js, and the
required tools. Use --fix for automatic fixes and --json for
machine-readable output.