fix(switch): accept noConnect prop so NC pins get do_not_connect - #815
Open
marcos452652258-gif wants to merge 1 commit into
Open
fix(switch): accept noConnect prop so NC pins get do_not_connect#815marcos452652258-gif wants to merge 1 commit into
marcos452652258-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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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