fix(schema): tenthmil no longer emits "NaNmil" for missing pad coordinate/size fields - #406
Open
bnuckols13 wants to merge 1 commit into
Open
fix(schema): tenthmil no longer emits "NaNmil" for missing pad coordinate/size fields#406bnuckols13 wants to merge 1 commit into
bnuckols13 wants to merge 1 commit into
Conversation
tenthmil (used by PadSchema, RectSchema, and TextSchema for coordinates and
sizes) is optional, but its transform ran `${Number.parseFloat(n) * 10}mil` on
every non-unit value. When a field is undefined — e.g. a short EasyEDA pad
string that omits holeRadius — Number.parseFloat(undefined) is NaN, producing
the nonsensical unit string "NaNmil".
Downstream in convert-easyeda-json-to-tscircuit-soup-json.ts, a "NaNmil"
holeRadius makes mil2mm(pad.holeRadius) !== 0 true, so the pad is treated as a
plated hole and emits NaN geometry — surfacing as "NaNmm" in the generated
component, the string the convert-to-ts tests guard against.
Guard the parse: fall back to 0 when Number.parseFloat yields NaN, matching the
safeNumber(0) convention already used in this file. A missing holeRadius now
reads as 0 (an SMT pad). Adds a regression test.
bnuckols13
force-pushed
the
fix/tenthmil-nanmil
branch
from
July 13, 2026 03:50
5c7919d to
43ba552
Compare
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.
Problem
tenthmil(used byPadSchema,RectSchema, andTextSchemafor coordinates and sizes) is.optional(), but its transform ran`${Number.parseFloat(n) * 10}mil`on every non-unit value. When a field isundefined— which happens when a short/variant EasyEDA pad string omits a trailing field such asholeRadius—Number.parseFloat(undefined)isNaN, producing the nonsensical unit string"NaNmil".Downstream in
convert-easyeda-json-to-tscircuit-soup-json.ts, a"NaNmil"holeRadius makesmil2mm(pad.holeRadius) !== 0true, so the pad is treated as a plated hole and emits NaN geometry — surfacing as"NaNmm"in the generated component (the exact string theconvert-to-tstests guard against withexpect(result).not.toContain("NaNmm")).Fix
Guard the parse: fall back to
0whenNumber.parseFloatyieldsNaN, matching thesafeNumber(0)convention already used in this file. A missingholeRadiusnow reads as0(an SMT pad) instead of NaN geometry.Repro
holeRadius: "NaNmil"holeRadius: "0mil"Tests
Adds
tests/parse-tests/pad-tenthmil-nan.test.ts(missing field → no NaN leak; valid inputs preserved). Existing suites stay green:parse-tests15,convert-to-soup-tests21,convert-to-ts59.