Skip to content

fix(pad): default w and h to 1mm so a bare pad renders (#788) - #789

Open
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/pad-default-dimensions
Open

fix(pad): default w and h to 1mm so a bare pad renders (#788)#789
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/pad-default-dimensions

Conversation

@zkasuran

@zkasuran zkasuran commented Aug 8, 2026

Copy link
Copy Markdown

Closes #788

pad is advertised by getFootprintNames(), but fp.string("pad").circuitJson() throws a raw TypeError because pad_def declares w and h with no defaults and pad() passes them to mm() without parsing. A missing dimension reaches @tscircuit/mm as undefined, so it throws undefined is not an object (evaluating 'n.replace'). The sibling smtpad defaults to a 1mm pad in the same situation, so smtpad renders from a bare name while pad crashes.

Repro

fp.string("pad").circuitJson()    // throws TypeError on main
fp.string("smtpad").circuitJson() // renders a 1mm pad

The change

Give pad_def a 1mm default for w and h (the same fallback smtpad uses) and parse the params through pad_def inside pad() so the defaults apply, matching how smtpad calls smtpad_def.parse. A bare pad now renders a 1mm square pad. Explicit dimensions still override, so fp().pad().w(2).h(1) is unchanged.

Verification

  • tests/pad_bare.test.ts renders fp.string("pad") to a PCB SVG snapshot and asserts a single 1mm pad.
  • The existing tests/pad.test.ts (sized w2 h1 and w3 h2) still passes unchanged.
  • No KiCad parity test: pad is a generic single SMD pad, not a named KiCad library footprint, so there is no reference to compare against. The parity harness fetches named KiCad footprints (for example Package_SON.pretty/VSON-8-1EP...), which a generic pad has no equivalent of.
  • Full suite green (522 pass), bun run build clean, biome format clean.

Disclosure

AI assistance (Claude, Anthropic) was used in developing this change. The design, review and verification were done by the author. Verified locally before submitting: the full bun test suite (522 pass), bun run build and biome format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pad throws a raw TypeError from a bare name while smtpad defaults its dimensions

1 participant