Passives
The common parts — resistors, capacitors, LEDs, diodes, inductors, fuses — are built into @typecad/pcb. There's no second package to install: import them from the package
root and pick the physical size with the size option.
Resistor / LED / Capacitor / Diode / Inductor / Fuse
Pre-built Component subclasses for the common passives. The size option selects the KiCAD symbol and footprint preset; an explicit footprint or symbol always wins over it.
Example first
import { PCB, Resistor, LED } from '@typecad/pcb';
let typecad = new PCB('typecad_docs');
let r1 = new Resistor({ value: '1kohm', size: '0805' });
let d1 = new LED({ value: 'green' }); // size defaults to '0603'Sizes
| size | Notes |
|---|---|
| '1210' | all component types |
| '1206' | all component types |
| '0805' | all component types |
| '0603' | all component types — the default |
| '0402' | no fuses |
| '0201' | no fuses |
Multiple sizes in one file
There are no size modules to import — pass a different size per part:
let r1 = new Resistor({ value: '1kohm', size: '0603' });
let c2 = new Capacitor({ value: '1uF', size: '0805' });Reference designators
| Case | Behavior |
|---|---|
| reference passed | Used as-is; a name conflict is renamed with a warning in the build output |
| reference omitted | Generated from the prefix property and an internal counter by type — R1, R2, C1... |
| prefix omitted | Type defaults: R for resistors, C for capacitors, D for LEDs, etc. |
Unique footprints
For a passive with a footprint outside the presets, pass it directly — an explicit footprint overrides the size preset:
let l1 = new Inductor({
value: '1uH',
footprint: 'Inductor_SMD:L_0805_2012Metric_Custom'
});passiveFactory
Builds a set of passive classes bound to one default size — the shape packages receive as this.passives. Handy on its own when a design mixes sizes heavily.
Example first
import { passiveFactory } from '@typecad/pcb';
const passives = passiveFactory('0805'); // everything defaults to 0805
let r1 = new passives.Resistor({ value: '10kohm' });
let c1 = new passives.Capacitor({ value: '100nF', size: '0402' }); // per-part size winsThe bound size is a default: an explicit size on an individual part
still wins. See Packages for how
package authors receive one of these automatically.