Skip to content

Make Via layer refs optional and add layers array; update schema and tests#668

Merged
seveibar merged 1 commit into
mainfrom
codex/add-optional-layout-properties
May 9, 2026
Merged

Make Via layer refs optional and add layers array; update schema and tests#668
seveibar merged 1 commit into
mainfrom
codex/add-optional-layout-properties

Conversation

@seveibar
Copy link
Copy Markdown
Contributor

@seveibar seveibar commented May 9, 2026

Motivation

  • Allow vias to be specified with an explicit layers array or omit explicit fromLayer/toLayer to support more flexible layer declarations and maintain backwards compatibility.

Description

  • Change ViaProps to make fromLayer and toLayer optional and add an optional layers?: LayerRefInput[] property in lib/components/via.ts.
  • Update the Zod schema viaProps to mark fromLayer/toLayer as optional and add layers: z.array(layer_ref).optional() for runtime validation.
  • Regenerate documentation files README.md, generated/COMPONENT_TYPES.md, and generated/PROPS_OVERVIEW.md to reflect the updated ViaProps shape.
  • Add a new test in tests/via.test.ts to validate parsing of layers and netIsAssignable, and keep the existing test for fromLayer/toLayer.

Testing

  • Ran the test suite with bun test and the updated tests/via.test.ts executed successfully.
  • Type-level checks using expectTypeOf against z.input<typeof viaProps> passed in the tests.

Codex Task

Comment thread tests/via.test.ts
Comment on lines +24 to +40
test("should parse ViaProps with layers and net assignability flag", () => {
const raw: ViaProps = {
name: "v2",
layers: ["top", "bottom"],
holeDiameter: "0.25mm",
outerDiameter: "0.6mm",
netIsAssignable: true,
}

expectTypeOf(raw).toMatchTypeOf<z.input<typeof viaProps>>()

const parsed = viaProps.parse(raw)
expect(parsed.layers).toEqual(["top", "bottom"])
expect(parsed.holeDiameter).toBe(0.25)
expect(parsed.outerDiameter).toBe(0.6)
expect(parsed.netIsAssignable).toBe(true)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The style guide states that a *.test.ts file may have AT MOST one test(...) call. This file now contains at least two test(...) blocks (the pre-existing one ending at line 22 and the newly added one starting at line 24). The new test should be moved into a separate, numbered file — for example via2.test.ts — so that each test file contains only a single test(...) call.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@seveibar seveibar merged commit c03d27e into main May 9, 2026
5 checks passed
@tscircuitbot
Copy link
Copy Markdown
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants