tscircuit / tscircuit/core

inductor drops maxCurrentRating: prop and schema field both exist, value never written

Open Beginner friendly
#2,837 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
58
Forks
203
Avg merge
7h 39m
Merged PRs (30d)
286

Description

What happens

maxCurrentRating is declared on InductorProps and max_current_rating exists on the simple_inductor circuit-JSON schema, but Inductor never writes it — the value is silently dropped:

<inductor name="L2" inductance="10uH" maxCurrentRating="2A" />
{
  "type": "source_component",
  "ftype": "simple_inductor",
  "name": "L2",
  "inductance": "10uH",
  "display_inductance": "10µH"
}

No max_current_rating anywhere in the output.

Both ends already exist
// @tscircuit/props — InductorProps
maxCurrentRating?: number | string;
// circuit-json — source_component, ftype "simple_inductor"
max_current_rating: z.ZodOptional<z.ZodNumber>;

So this is purely a missing hand-off in Inductor.doInitialSourceRender(), which inserts inductance, display_inductance, supplier_part_numbers, manufacturer_part_number and display_name, but not the rating. Anything downstream reading max_current_rating (BOM export, part selection, DRC on current limits) sees nothing, with no warning that the prop was ignored.

A wrinkle worth flagging for whoever fixes it

maxCurrentRating has no zod transform, unlike capacitor's maxVoltageRating:

capacitor: maxVoltageRating: z.ZodOptional<z.ZodEffects<...>, number, string | number>>  ← converts to number
inductor:  maxCurrentRating: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>        ← raw

So the raw string reaches the component and a naive parseFloat("500mA") yields 500, not 0.5 — off by 1000×. parseSiUnit doesn't work either (it returns NaN for "2A", since it doesn't expect a unit suffix); parseAndConvertSiUnit(...).value handles both:

"2A"    → 2
"500mA" → 0.5
"1.5A"  → 1.5
"2"     → 2
"abc"   → NaN
How I found it

Cross-referenced every *Props interface in @tscircuit/props against the props each component actually reads. Other hits from the same sweep that may or may not be intentional: Capacitor.bypassFor/bypassTo/schSize, Resistor.schSize/tolerance, Board.topSolderMaskColor/bottomSolderMaskColor/doubleSidedAssembly, Chip.internalCircuit/pinCompatibleVariants. I'm only filing this one because it's the one where the destination schema field already exists, so the fix is unambiguous.

PR ready.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Inductor.doInitialSourceRender(), then compare its existing property hand-offs with capacitor's maxVoltageRating handling. Verify that maxCurrentRating reaches max_current_rating with correct SI-unit values, including 2A, 500mA, 1.5A, 2, and invalid input; done means the circuit-JSON output contains the rating.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.