fix(switch): accept noConnect prop so NC pins get do_not_connect - #815
fix(switch): accept noConnect prop so NC pins get do_not_connect#815marcos452652258-gif wants to merge 1 commit into
Conversation
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.
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
|
Hi maintainers, pinging for a review on this fix — it's still relevant. Let me know if any changes are needed. Thanks! |
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
|
Hi maintainers, pinging to keep this PR active — it is still tested, relevant and ready for review whenever you have time. Thank you! |
|
Still relevant — keeping active per contribution guidelines. |
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
|
Hi maintainers, pinging to keep this PR active — it is still tested, relevant and ready for review whenever you have time. Thank you! |
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
|
Hi maintainers, pinging to keep this PR active — it is still tested, relevant and ready for review whenever you have time. Thank you! |
Root cause
switchProps(intscircuit/props) did not declare anoConnectfield 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()readsparentProps.noConnectand pushes{ doNotConnect: true }for matching pins — but for switches that prop was alwaysundefined, so source ports were created withoutdo_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.tsxonly covered<chip>, whose schema does declarenoConnect, which is why this went unnoticed.Fix
noConnectPropzod schema fromlib/components/chip.tsnoConnect: noConnectProp.optional()toswitchPropsSwitchPropsTypeScript interface with a doc comment{ type: "spdt", noConnect: ["pin3"] }preserves["pin3"]Verification
bun test tests/switch.test.ts: 5 pass (incl. new regression test)bun run typecheck: cleanbun run format:check: cleanFixes tscircuit/tscircuit#4443