Components
A component is anything that has a KiCAD symbol or footprint — resistors, MCUs, vias, mounting
holes, or regulatory images. The Component class is the base class for all of them.
Component
The base class for all components in typeCAD — in KiCAD terms, anything that has a footprint file associated with it. Construct it directly for simple parts, or extend it with named pins for ICs (usually via the add-component tool, below).
Example first
import { Component } from '@typecad/pcb';
let u1 = new Component({ footprint: 'Package_SO:SOIC-8_5.3x5.3mm_P1.27mm' });Options
| Option | Type | Description |
|---|---|---|
| reference | string | Reference designator (R1, U2...) |
| value | string | Value of component |
| footprint | string | KiCAD footprint path, e.g. Package_SO:SOIC-8_5.3x5.3mm_P1.27mm |
| symbol | string | KiCAD symbol library path |
| prefix | string | Prefix for reference designator |
| datasheet | string | Link to component datasheet |
| description | string | Description of component |
| voltage | string | Voltage rating of component |
| wattage | string | Wattage rating of component |
| mpn | string | Manufacturer Part Number |
| dnp | boolean | true if Do Not Populate |
| simulation | object | { include: true, model: 'ngspice-model' } |
| pcb | object | Position on the board { x, y, rotation } |
| text | array | Arbitrary text entries on the board, with property, text, position, styling |
| fab | object | Fabrication layer text entry — a positioning object or [text, positioning] tuple |
| referenceLayout | object | Reference designator text position and style (defaults to F.SilkS) |
| valueLayout | object | Value text position and style (defaults to F.Fab) |
| fabLayout | object | Fab text position and style (defaults to F.Fab; text defaults to ${REFERENCE}) |
The three layout properties (referenceLayout, valueLayout, fabLayout) accept an ITextPositioning object and can be set at
construction or assigned after creation.
pin pin(number, config?): Pin
Creates and registers a pin — see Pins & Power.
In generated component files this is how named pins (u1.VCC) are defined.
Connectors & mechanical parts
A few common non-IC parts ship as ready-made classes, alongside the passives — all from the package root:
import { Connector, TestPoint, MountingHole, NetTie } from '@typecad/pcb';
let j1 = new Connector({ number: 4 }); // 1x04 pin header (series presets: 'pin-header', 'JST-SH')
let tp1 = new TestPoint(); // 1.0 mm pad probe point
let mh1 = new MountingHole({ size: 'M3' }); // M2–M8 presets
let tie1 = new NetTie({ net1: 'VBUS', net2: 'VOUT' }); // ties two nets, pin count follows the netstypecad add component
The better way to create components. Run typecad-pcb add component from the ./hw directory, or click the add_component button in the VSCode GUI
under NPM Scripts. It asks where the component comes from — the KiCAD library, a local file, or
an EasyEDA/JLCPCB part — and generates a .ts file like this:
import { Component } from '@typecad/pcb';
/**
| Pin # | Name | Type |
| --: | :-- | :-- |
| 8 | VCC | power_in |
| 4 | GND | power_in |
| 5 | AREF_PB0 | bidirectional |
| 1 | _RESET_PB5 | bidirectional |
*/
export class ATtiny85_20S extends Component {
VCC = this.pin(8, { type: 'power_in' });
GND = this.pin(4, { type: 'power_in' });
AREF_PB0 = this.pin(5, { type: 'bidirectional' });
_RESET_PB5 = this.pin(1, { type: 'bidirectional' });
constructor(reference?: string | undefined) {
super("Package_SO:SOIC-8_5.3x5.3mm_P1.27mm");
this.symbol = "MCU_Microchip_ATtiny:ATtiny85-20S";
if (reference) this.reference = reference;
}
}The file extends Component and adds Pin objects — so instead of u1.pin(1) you write u1.VCC. Use the generated class like any other:
import { ATtiny85_20S } from './ATtiny85_20S';
let u1 = new ATtiny85_20S();Finding parts: typecad-pcb search
typecad-pcb search "voltage regulator"
typecad-pcb search LM358
typecad-pcb search "SOIC-8" --footprint --jsonFuzzy-matches against the KiCAD symbol libraries and returns the symbol name, footprint, and
description, in LibraryName:SymbolName format. With --footprint, it
searches the installed footprint libraries instead — results include the pad numbers. Options: --format (detailed, compact, table, json), --sort (score, id,
manufacturer, package), --limit (default 5).