Skip to content

shouldBeOnEdgeOfBoard prop typechecks but is never consumed by the auto-placer #2271

@gsdali

Description

@gsdali

Summary

shouldBeOnEdgeOfBoard is declared on pcbLayoutProps (so every
component that extends those layout props — chips, resistors, caps,
diodes, plated holes, etc.) and shows up in TypeScript completion,
but the runtime never reads it. Setting it on a component is a
no-op today.

$ rg 'shouldBeOnEdgeOfBoard' /path/to/tscircuit/core/lib/
# (no results — the prop is parsed by zod but never consumed)

This is the same shape of bug as #2242 (pcbPositionMode typechecks
but unused, fixed in #2247) and #2270 (<platedhole connectsTo>
typechecks but disconnected) — a documented prop the runtime ignores.

Repro

<board width="40mm" height="14mm">
  {/* User declares "this part must end up on the board edge". */}
  <chip
    name="J_USB"
    shouldBeOnEdgeOfBoard
    footprint={...usb-c receptacle...}
    connections={...}
  />
  <resistor name="R1" resistance="10k" footprint="0402" />
  <resistor name="R2" resistance="10k" footprint="0402" />
</board>

Expected: the auto-placer constrains J_USB to a position where its
courtyard touches a board edge.

Actual: prop has no observable effect; J_USB packs interior with
the resistors based on the default packPlacementStrategy.

Why it matters

This is the missing knob for the most common manual-placement task on
real boards: connectors and through-holes that must reach the
board edge so cables can plug in or wires can be soldered. Today the
workaround is to hand-place every edge-mounted part with explicit
pcbX/pcbY (we ended up doing this for ~9 components on a 45×14 mm
board); a working shouldBeOnEdgeOfBoard would let users delegate
the X/Y picking to the packer for the parts that don't care about
specific position, only "must be on an edge".

Suggested fix shape

Two-repo change. Sketch:

  1. tscircuit/calculate-packing — add mustBeOnBoundary?: boolean
    (or similar) to InputComponent. The PackSolver2 candidate-scorer
    already considers the board outline; for components flagged this
    way, candidate positions whose courtyard doesn't touch the
    boundaryOutline are excluded.

  2. tscircuit/core — in
    Group_doInitialPcbLayoutPack.ts, when building the PackInput
    for the solver, propagate _parsedProps.shouldBeOnEdgeOfBoard
    from each child onto the corresponding InputComponent entry.

A "nearest of any edge" semantics is the simplest first cut. Future
extension: shouldBeOnEdgeOfBoard: "left" | "right" | "top" | "bottom" | true for finer control.

Workaround until fixed

Set explicit pcbX/pcbY on every edge-anchored part. For boards with
many connectors / through-holes this is the bulk of the manual
placement work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions