fix: carry inductor maxCurrentRating into source_component (#2837)#2838
fix: carry inductor maxCurrentRating into source_component (#2837)#2838DPS0340 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
49b6f1a to
4c759f5
Compare
|
Housekeeping — rebased onto current Since I have several PRs open here now, a note on how they interact so none of this lands on you: Five of the seven are fully independent — they touch different files and merge in any order:
Two pairs conflict, and both are trivial:
Happy to do the merge myself: say the word and I'll combine any subset into a single PR, or rebase the losers as soon as the first one lands. I'd rather you not spend time on conflict resolution for my changes. I verified the above rather than assuming it — checked all 21 branch pairs for conflicts and confirmed each rebases cleanly onto |
4c759f5 to
683fac1
Compare
Closes #2837.
maxCurrentRatingis declared onInductorPropsandmax_current_ratingexists on thesimple_inductorschema, butdoInitialSourceRender()never wrote it — the value was dropped with no warning.The part that isn't obvious
My first attempt used
parseFloat, copyingFuse's approach, and the checker caught it:parseFloat("500mA")returns 500 — a 1000× error that would have written a plainly wrong value into circuit JSON rather than leaving it absent.The reason
Fusegets away withparseFloatis that its ratings are conventionally written without SI prefixes.maxCurrentRatinghas no zod transform either, unlike capacitor'smaxVoltageRating:I then tried
parseSiUnit, which returnsNaNfor"2A"— it doesn't expect a unit suffix.parseAndConvertSiUnit(...).valueis the one that handles both, which I verified directly before using it:NaN/null/undefinedall resolve toundefinedso a malformed rating leaves the field absent rather than poisoning it.Verification
The test bites. Reverting only
Inductor.ts:It covers all four cases in one board — omitted, string with unit, plain number, and prefixed unit — so the 1000× bug specifically is pinned by
expect(ratingByName.L4).toBe(0.5).Suite:
1260 pass / 0 fail, no snapshots changed (this only adds a source field).biome formatandtsc --noEmitclean.Other props from the same sweep
I cross-referenced every
*Propsinterface against the props each component reads. Several others appear unread —Capacitor.bypassFor/bypassTo/schSize,Resistor.schSize/tolerance,Board.topSolderMaskColor/bottomSolderMaskColor,Chip.internalCircuit/pinCompatibleVariants. I deliberately didn't touch those: unlike this one they have no obvious destination field, so "fixing" them would mean inventing schema semantics. Listed in #2837 in case they're worth triaging.