fix: validate fuse connections against its pin labels (#754)#755
fix: validate fuse connections against its pin labels (#754)#755DPS0340 wants to merge 1 commit into
Conversation
|
Withdrawing this one on queue grounds rather than anything about the change itself. I counted my own output across every repo I contribute to. Among PRs a maintainer actually decided, 57% merged — but 94% of what I have opened has never been looked at by a human at all. The constraint was never quality; I was handing out more review work than anyone could absorb. This PR fixes an issue I filed myself, which is the shape most of that volume took: find something, report it, fix it, and hand a maintainer work nobody asked for. I am closing the self-originated ones across every repo and keeping only those that answer someone else's bug report. The branch stays up and the issue stays open, so nothing is lost. If this one is actually wanted, say so and I will reopen it. Sorry for the noise. |
Fixes #754.
What was wrong
fusePropsaccepted any string as aconnectionskey. Same typo, same class of component, opposite result:{ "not a pin at all": ... }and{ "": ... }got through too.Two gaps caused it:
The schema was hand-rolled. Every other component does
createConnectionsProp(<its>PinLabels), which keys the record onz.enum(labels). Fuse used a barez.record(z.string(), ...), so any key passed — even though the file already defines and exportsfusePinLabels = ["pin1", "pin2"].Nothing held the schema to the interface.
FusePropsdeclaredconnections?: Connections<PinLabel>while the schema producedRecord<string, ...>. Fuse is the only file inlib/components/that exports both an interface and anInferred*type without callingexpectTypesMatch— I checked all 20 files that omit it, and the other 19 don't export both, so this was the single gap. Dropping the assertion into the file as-shipped fails to compile:The types had silently drifted because the invariant was never applied here.
The fix
Three lines of substance, all bringing fuse in line with the existing convention:
connections: createConnectionsProp(fusePinLabels).optional()— the same helper and the same pin-label source everything else uses.connections?: Connections<FusePinLabels>on the interface, matching howCapacitorPropsandResistorPropspin theirs to concrete labels rather than the freePinLabelparameter.expectTypesMatch<FuseProps, InferredFuseProps>(true)at the bottom, so this can't drift again.No new helper, no new convention — the repo already had all of it.
Tests
tests/fuse-connections.test.ts, five tests pinning both directions:pin1,pin2, and both togetherpin99,"not a pin at all",""fusePropsvscapacitorPropsfalsereadonlyarray targets onpin1connectionsat allThe comparison test is the one that matters: it fails if fuse and the other two-pin passives ever disagree again, in either direction. The last two rows are guard rails against over-tightening — a change that simply rejected more would break them.
Bite-proofed: reverting only
lib/components/fuse.tstakes the file from 5 pass to 3 pass / 2 fail.Verification
bun test: 388 pass / 0 fail (baseline onmainis 383 pass / 0 fail; +5 new).bunx tsc --noEmitclean — which is itself part of the fix, since the newexpectTypesMatchwould fail the type-check if the schema and interface disagreed.bun run format:checkclean.