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).

functions

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

checks.ts
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);
functions

exportPCB / exportSchematic

Export the board or schematic to a file format — svg, pdf, and the other kicad-cli export formats.

Example first

export.ts
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');
functions

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

cli.ts
import { executeKiCADCommand } from '@typecad/pcb';

const version = await executeKiCADCommand('kicad-cli', ['version'], {});
console.log(version);

All functions

FunctionDescription
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:

typecad.conf.ts
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,
});
OptionTypeDescription
entrystringPath to the TypeScript entry file (relative to hw/)
kicad_clistringPath to the kicad-cli binary
kicad_pathstringPath to the KiCAD installation directory
use_flatpakbooleanPrioritize a Flatpak installation
verbosebooleanVerbose output during builds
rulesstringPath 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.

© 2026 typeCAD — code-defined electronics github