The PCB class
PCB is the main class — it represents the entire circuit. Components are added to it,
connections are made through it, board layout is defined on it, and the utility functions (ERC,
BOM, routing) hang off it. One PCB per board; connections are made between components
in the same PCB.
PCB
The board. Construct it with a name (the only required option — it determines the names of the resulting KiCAD files), add components and connections, then create().
Example first
import { PCB } from '@typecad/pcb';
import { ATtiny85_20S } from './ATtiny85_20S';
let typecad = new PCB('typecad_concepts', { thickness: 1.6, copper_thickness: 35 });
let u1 = new ATtiny85_20S();
typecad.net(u1.VCC, u1.GND);
typecad.create(u1);Constructor options
| Option | Type | Units | Description |
|---|---|---|---|
| Boardname | string | required | Name and filename of the generated files |
| options.thickness | number | mm | Board thickness |
| options.copper_thickness | number | microns | Copper thickness (1 oz = 35 microns) — used in power-aware calculations |
The thicknesses are used in power-aware calculations. The name determines ./build/{name}.kicad_pcb, .kicad_sch, .net, and .csv.
create create(...items): void
After components have been created and modified, call create to include them in
the PCB, schematic, and netlist. Accepts components, buses, tracks, and vias.
All methods
| Member | Description |
|---|---|
| new PCB(name, options?) | Create the board; the name determines the output filenames |
| create(...items) | Include components, tracks, vias, and buses in the PCB, schematic, and netlist |
| net(...pins) | Connect any number of pins (see Connections) |
| named(name) | Name the next net — visible in KiCAD |
| route(net | { from, to }, options?) | Auto-route a connection (see Routing) |
| track() | Start a manual track — returns a TrackBuilder |
| via({ at, size, drill }) | Create a via; connect through pin(1) |
| outline(x, y, w, h, fillet?) | Rectangle board outline |
| zone(options) / keepout(options) | Copper pours and keepout areas |
| group(name, ...components) | Group components on the PCB |
| place(...components) | Place components on the board at their assigned positions |
| board | Live board bounds — center, edges, corners (see Placement) |
| rect / circle / line / poly / text | Graphics primitives on the board |
| bom() | Bill of materials data |
| stage(...items) | Stage components without emitting them |
Package
Abstract base class for reusable, importable hardware modules. Extend it to encapsulate a circuit sub-design — a voltage regulator, sensor module, or MCU subsystem — and publish it as an npm package.
Example first
import { Package, Component } from '@typecad/pcb';
export class MyResistor extends Package {
declare resistor: Component;
build(options) {
this.resistor = new this.passives.Resistor({ value: '10kohm' });
this.resistor.pcb = { x: 100, y: 100, rotation: 0 };
}
}The constructor handles offset positioning (x, y), auto-collects all Component properties set on this, groups them on the PCB, and
automatically syncs the package's bundled KiCAD symbol/footprint files (its ./build/lib/) into the project's ./build/lib/ directory — no install
script required. For classes that don't extend Package, the exported syncThisPackageBuildLib() helper provides the same sync with one call.