Summary
The string parser does not correctly handle imperial/metric size codes for led and diode footprints. While res0402 and cap0603 work correctly, led0402 and diode0603 throw an error:
Error: Could not determine required pad dimensions (p, pw, ph)
Root Cause
In src/footprinter.ts, the proxy handler only recognizes res and cap as passive footprints that use imperial/metric sizing:
if (prop === "res" || prop === "cap") {
target.imperial = v // correctly sets imperial size
} else {
target.num_pins = Number.parseFloat(v) // incorrectly treats as pin count
}
So led0402 gets parsed as { fn: "led", num_pins: 402 } instead of { fn: "led", imperial: "0402" }.
Reproduction
import { fp } from "@tscircuit/footprinter"
// These work:
fp.string("res0402").circuitJson() // ✓
fp.string("cap0603").circuitJson() // ✓
fp().led().imperial("0402").circuitJson() // ✓ (builder API works)
// These fail:
fp.string("led0402").circuitJson() // ✗ Error
fp.string("led0603").circuitJson() // ✗ Error
fp.string("diode0402").circuitJson() // ✗ Error
fp.string("diode0805").circuitJson() // ✗ Error
Expected Behavior
All four passive footprint types (res, cap, led, diode) should support the same <name><imperial_size> string syntax, since they all delegate to the same passive() function.
Impact
Users cannot use standard footprint strings for LED and diode passive packages. They must use the builder API instead, which is inconsistent with the res/cap behavior.
Summary
The string parser does not correctly handle imperial/metric size codes for
ledanddiodefootprints. Whileres0402andcap0603work correctly,led0402anddiode0603throw an error:Root Cause
In
src/footprinter.ts, the proxy handler only recognizesresandcapas passive footprints that use imperial/metric sizing:So
led0402gets parsed as{ fn: "led", num_pins: 402 }instead of{ fn: "led", imperial: "0402" }.Reproduction
Expected Behavior
All four passive footprint types (
res,cap,led,diode) should support the same<name><imperial_size>string syntax, since they all delegate to the samepassive()function.Impact
Users cannot use standard footprint strings for LED and diode passive packages. They must use the builder API instead, which is inconsistent with the
res/capbehavior.