Skip to content

fix(switch): accept noConnect prop so NC pins get do_not_connect - #815

Open
marcos452652258-gif wants to merge 1 commit into
tscircuit:mainfrom
marcos452652258-gif:fix/switch-noconnect-prop
Open

fix(switch): accept noConnect prop so NC pins get do_not_connect#815
marcos452652258-gif wants to merge 1 commit into
tscircuit:mainfrom
marcos452652258-gif:fix/switch-noconnect-prop

Conversation

@marcos452652258-gif

Copy link
Copy Markdown

Root cause

switchProps (in tscircuit/props) did not declare a noConnect field in its zod schema. Zod silently strips unknown keys during parsing, so <switch noConnect={["pin3"]} /> lost the prop before it ever reached the component.

Downstream, Port._getMatchingPinAttributes() reads parentProps.noConnect and pushes { doNotConnect: true } for matching pins — but for switches that prop was always undefined, so source ports were created without do_not_connect. That is exactly the behavior reported in tscircuit/tscircuit#4443 (noConnect prop does not set do_not_connect on source ports).

The existing regression test chip-no-connect-prop.test.tsx only covered <chip>, whose schema does declare noConnect, which is why this went unnoticed.

Fix

  • Export the existing noConnectProp zod schema from lib/components/chip.ts
  • Add noConnect: noConnectProp.optional() to switchProps
  • Add the field to the SwitchProps TypeScript interface with a doc comment
  • Add a regression test: parsing { type: "spdt", noConnect: ["pin3"] } preserves ["pin3"]

Verification

  • bun test tests/switch.test.ts: 5 pass (incl. new regression test)
  • Full suite: 451 pass / 0 fail
  • bun run typecheck: clean
  • bun run format:check: clean

Fixes tscircuit/tscircuit#4443

The switchProps zod schema did not declare noConnect, so the prop was
silently stripped during parsing. Port._getMatchingPinAttributes() never
saw it and source ports were left without do_not_connect, causing false
missing-trace warnings (tscircuit/tscircuit#4443).

Reuse the existing chip noConnectProp schema and add a regression test.
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.

noConnect prop does not set do_not_connect on source ports

1 participant