tscircuit / tscircuit/core

Inline <footprint> components get no silkscreen reference designator

Open
#2,875 9 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

Summary

A component using an inline <footprint> gets no silkscreen reference designator, while the same component using a string footprint does.

// string footprint
<chip name="U1" footprint="soic8" />
// → pcb_silkscreen_text: ["U1"]

// inline footprint
<chip name="J1" footprint={
  <footprint>
    <smtpad pcbX={-0.5} pcbY={0} width="0.55mm" height="1.1mm" shape="rect" portHints={["pin1"]} />
    <smtpad pcbX={0.5}  pcbY={0} width="0.55mm" height="1.1mm" shape="rect" portHints={["pin2"]} />
  </footprint>
} />
// → pcb_silkscreen_text: []

Verified directly against current main:

STRING: silkscreen_text= [ "U1" ]   cad_component= 1
INLINE: silkscreen_text= []         cad_component= 1

The board renders and exports without any error, so the missing designator only shows up when you look at the silkscreen — or when an exporter needs it. This is the root cause behind tscircuit/circuit-json-to-kicad#51 ("Footprint files are missing things like reference designator"): the KiCad converter can't emit fp_text reference from data that isn't in the circuit JSON.

Cause

NormalComponent._addChildrenFromStringFootprint() has a single typeof footprint === "string" branch:

if (typeof footprint === "string") {
  const fpCircuitJson = fp.string(footprint).soup()
  const fpComponents = createComponentsFromCircuitJson(
    { componentName: this.name ?? this.componentName, ... },
    fpCircuitJson,
  )
  this.addAll(fpComponents)
}

Footprinter emits a pcb_silkscreen_text placeholder, and createComponentsFromCircuitJson rewrites its text to the component name:

text: componentName || elm.text,

Inline JSX footprints never enter that function, so nothing ever creates the designator for them.

Expected

An inline footprint should get the same reference designator a string footprint gets, placed clear of the footprint bounds, on the component's layer, and without duplicating one the footprint already declares.

PR follows.

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 NormalComponent._addChildrenFromStringFootprint() and compare the string-footprint path with inline child handling. Check how createComponentsFromCircuitJson rewrites pcb_silkscreen_text and how the inline footprint is represented. Done means inline footprints produce one component-name silkscreen reference, placed clear of the footprint bounds, without duplicating an existing declaration.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.