Skip to content

Conversation

@Enity300
Copy link

@Enity300 Enity300 commented Nov 2, 2025

Fixes #1516
image

Issue: When outline property is opted, previously width and height were also being updated to what the outline bounds tells it. This was needed to be fixed to not cause any ambiguity for the user in the future.

Fix: When a board has an outline property, width and height are now left as undefined instead of being calculated from the outline bounds. This removes ambiguity about whether the board shape is defined by width/height or by the outline.

Changes:

  • Board.doInitialPcbComponentRender: Don't calculate width/height when outline exists
  • Board.doInitialPcbBoardAutoSize: Skip width/height update when outline is present
  • Added repro70-board-outline.test.tsx to verify width/height are undefined with outline
  • Board-outline-dimension.test.tsx: this test file was created for issue 1514, changed the test to expect width as undefined rather than excepting 16
image

Fixes tscircuit#1516

When a board has an outline property, width and height are now left as undefined
instead of being calculated from the outline bounds. This removes ambiguity about
whether the board shape is defined by width/height or by the outline.

Changes:
- Board.doInitialPcbComponentRender: Don't calculate width/height when outline exists
- Board.doInitialPcbBoardAutoSize: Skip width/height update when outline is present
- Added repro70-board-outline.test.tsx to verify width/height are undefined with outline
- Updated board-outline-dimension.test.tsx to expect undefined instead of 16
@vercel
Copy link

vercel bot commented Nov 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview Comment Nov 12, 2025 7:01am

- Removed 'as any' typecast from pcb_board.insert() as requested by maintainer
- Updated board-outline-dimension snapshot to reflect new behavior
- TypeScript errors will be resolved when circuit-json types are updated to allow undefined for width/height
Copy link
Contributor

@MustafaMulla29 MustafaMulla29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type check and other workflows are failing

Copy link
Contributor

@nailoo nailoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy to fix, please update snapshots

@Enity300
Copy link
Author

Enity300 commented Nov 2, 2025

@MustafaMulla29 @nailoo , the type script error is due to the typescript definition not being defined, the issue was to keep the width and height undefined when using outline property. Since Rishabh requested to not to type cast to any, the problem arises that width and height cannot be undefined as they expect a number.

For the bun test failing, I have talked to Rishabh on discord about the same, and am waiting for his reply. Here the issue turned out to be more than updating snapshots, at first I did indeed updated the snapshots but the difference between the snapshots are causing the error. After implementing the change to set width/height as undefined when outline is present, I discovered breaking issues throughout the codebase:

Problems found:

  • 3D snapshot camera positioning relies on board.width and board.height (causes NaN → blank renders)

The Issue:
Making width/height undefined breaks too many parts of the system that expect these values to exist. Utilities would need to be updated to fallback to calculating from outline.

this particular file is causing the snapshot issue: tests/features/pcb-pack-layout/pcb-pack-cad-component-rotation.test.tsx

image

this screenshot, shows it properly, before the height and width being undefined the snapshot is the left image, after fixing the issue mentioned in #1516 in the Boards.ts script the updated snapshot is on the right.

Please note that my code is not breaking the elements, as in this code: tests/repros/repro62-xiao-board-rp2040-pcb-packing.test.tsx

proof :
image

only the two mentioned code files uses "xiao board rp2040 pcb packing", that is what I am getting when the bun test fails for merging.

So if any of you guys can help me with these two issues, it would be very much appreciated.

@seveibar
Copy link
Contributor

seveibar commented Nov 4, 2025

need to also add the shape property as the original comment stated

@Enity300
Copy link
Author

Enity300 commented Nov 4, 2025

need to also add the shape property as the original comment stated

let me add that, in that case

…used rendering and testing issues with custom board outlines. By explicitly tracking board geometry type, downstream tools can correctly handle both rectangular boards (with width/height) and outlined boards (with custom point arrays) without ambiguity.

Added shape property to PCBBoard type to distinguish between rectangular and outlined boards, ensuring proper handling of board geometry throughout the rendering pipeline.

Changes Made:
Type Definition Enhancement (circuit-json.d.ts):

Extended PCBBoard interface with optional shape property ("rectangular" | "outlined")
Enables explicit identification of board geometry type in circuit JSON
Board Component Update (Board.ts):

Added shape property assignment during PCB board initialization
Automatically sets shape: "outlined" when outline is provided, otherwise "rectangular"
Ensures board shape metadata is consistently present in generated circuit JSON
3D Snapshot Testing Fix (extend-expect-3d-matcher.ts):

Updated camera positioning logic to handle outlined boards separately from rectangular boards
For outlined boards, calculates dimensions from outline points instead of using width/height
Fixes camera positioning issues when rendering 3D snapshots of custom board shapes
Test Snapshot Update (footprint-library-map3.test.tsx):

Updated test expectation to include shape: "rectangular" in snapshot
Ensures test compatibility with new board shape property
@Enity300
Copy link
Author

Enity300 commented Nov 4, 2025

Hi! While implementing the shape property for outlined boards, I ran into a TypeScript compilation error.

The issue is that the PCBBoard interface in the circuit-json package currently requires width and height to be numbers. However, when a board uses a custom outline, the width and height properties shouldn't be present at all - the board dimensions come from the outline points instead.

Right now, I'm trying to conditionally set width and height to undefined when an outline is present, but TypeScript is rejecting this because it expects those fields to always be numbers, not undefined.

Could you update the circuit-json package to make the width and height properties optional on the PCBBoard interface? This would allow rectangular boards to specify width and height normally, while outlined boards can omit these properties and rely solely on the outline.

This is currently blocking the PR because the type-check tests are failing, which is in turn causing build test failure

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

- Upgraded circuit-json to 0.0.303 (includes optional width/height and shape property)
- Added shape property to Board: "rect" for rectangular, "polygon" for outlined boards
- Fixed 22 TypeScript errors by adding proper undefined checks for width/height
- Updated get-board-polygon.ts, getSimpleRouteJsonFromCircuitJson.ts, is-route-outside-board.ts
- Updated test fixtures and snapshots to handle optional width/height
- Board info silkscreen now skips boards without width/height
Copy link
Member

@imrishabh18 imrishabh18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, LGTM!

Enity300 and others added 2 commits November 7, 2025 23:42
Co-authored-by: Rishabh Gupta <38923768+imrishabh18@users.noreply.github.com>
Co-authored-by: Rishabh Gupta <38923768+imrishabh18@users.noreply.github.com>
if (!pcbBoard) return

// Only add board information for rectangular boards with width/height
if (!pcbBoard.width || !pcbBoard.height) return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduces bug

@seveibar
Copy link
Contributor

seveibar commented Nov 9, 2025

this issue is valid but i don't think it's important enough where we can risk the upstream breakage w.r.t. undefined width and height. Reduce scope to just add the shape property

@Enity300
Copy link
Author

Enity300 commented Nov 9, 2025

this issue is valid but i don't think it's important enough where we can risk the upstream breakage w.r.t. undefined width and height. Reduce scope to just add the shape property

In that case, should I also revert the changes made in this pr: tscircuit/circuit-json#339 by opening another pr ? @seveibar

@github-actions
Copy link

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@seveibar
Copy link
Contributor

@Enity300 no it's not necessary to revert the changes, i'm saying that we can leave tscircuit/core out-of-spec. But you can add shape to board to bring us closer to spec. Sometimes we wait until a big release to fix things that are out of spec so that we're not breaking too much at once

@Enity300
Copy link
Author

@Enity300 no it's not necessary to revert the changes, i'm saying that we can leave tscircuit/core out-of-spec. But you can add shape to board to bring us closer to spec. Sometimes we wait until a big release to fix things that are out of spec so that we're not breaking too much at once

Understood, I have not reverted any changes made to circuit-json, but have only updated boards.ts for shape property and have reduced the scope of undefined for now @seveibar

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.

Board with outline should have the width and height as undefined

5 participants