Skip to content

fix: omit fontSize on silkscreentext when font_size is null#31

Open
gsdali wants to merge 1 commit intotscircuit:mainfrom
gsdali:fix-silkscreen-fontsize-null
Open

fix: omit fontSize on silkscreentext when font_size is null#31
gsdali wants to merge 1 commit intotscircuit:mainfrom
gsdali:fix-silkscreen-fontsize-null

Conversation

@gsdali
Copy link
Copy Markdown

@gsdali gsdali commented May 6, 2026

Summary

pcb_silkscreen_text elements parsed from kicad_mod files often lack a font_size field (when the source omits the (effects (font (size N N))) clause). The generator was emitting fontSize={null} in that case, producing TSX that fails downstream typecheck because SilkscreenTextProps.fontSize rejects null/undefined.

components/footprints/Isp3080UxFootprint.tsx(174,70): error TS2322:
Type 'null' is not assignable to type 'string | number | undefined'.

Fix

Build the <silkscreentext> attribute list conditionally — only include fontSize= when stext.font_size != null. When omitted, the renderer's default applies. Behavior when font_size IS set is unchanged (existing test4 snapshot still matches).

Repro / motivation

Hit while running tsci convert on a 157-pad LGA InsightSiP kicad_mod from a community KiCad library. Every output file required hand-removing fontSize={null} from a single line before it would typecheck — same fix every time.

Test plan

  • Existing test4 (silkscreen with font_size set) — snapshot unchanged ✓
  • New test4b (silkscreen without font_size) — asserts no fontSize={null} or fontSize={undefined} in output ✓
  • bun test: 16 / 16 pass
  • bun run format:check: clean

🤖 Generated with Claude Code

pcb_silkscreen_text elements parsed from kicad_mod files often
lack a font_size (when the source omits the (effects (font (size
N N))) clause). The generator was emitting fontSize={null} in
that case, producing TSX that fails downstream typecheck because
SilkscreenTextProps.fontSize rejects null/undefined.

Fix: build the silkscreentext attribute list conditionally — only
include fontSize= when stext.font_size != null. When omitted,
the renderer's default applies.

Add a regression test (test4b) demonstrating that a silkscreen text
without font_size produces TSX that contains neither
fontSize={null} nor fontSize={undefined}.

Hit while running `tsci convert` on a 157-pad LGA kicad_mod —
every output file required hand-removing fontSize={null} from a
single line before it would typecheck.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant