Skip to content

feat: add PDIP and SPDIP as separate footprint functions#561

Open
iprevail-io wants to merge 3 commits intotscircuit:mainfrom
iprevail-io:feat/pdip-spdip-aliases
Open

feat: add PDIP and SPDIP as separate footprint functions#561
iprevail-io wants to merge 3 commits intotscircuit:mainfrom
iprevail-io:feat/pdip-spdip-aliases

Conversation

@iprevail-io
Copy link

/claim #371

Summary

  • PDIP (Plastic DIP) and SPDIP (Shrink Plastic DIP) are standard DIP package variants that weren't recognized by the string parser
  • Added normalization in normalizeDefinition() so pdip8dip8 and spdip28dip28
  • Also addresses Implement SPDIP-28 #180 (SPDIP-28)

Changes

  • src/footprinter.ts: Two regex rules in normalizeDefinition()
  • tests/pdip.test.ts: 6 new tests (alias resolution, case insensitivity, pad count verification, SVG snapshot)

Test plan

  • pdip8 resolves to same params as dip8
  • Case-insensitive (PDIP8 = pdip8)
  • pdip8 generates exactly 8 plated holes
  • spdip28 resolves to same params as dip28
  • spdip28 generates exactly 28 plated holes
  • Full suite: 390/390 pass

PDIP (Plastic DIP) and SPDIP (Shrink Plastic DIP) are standard DIP
package variants. This adds string normalization so footprint strings
like "pdip8" and "spdip28" resolve correctly to the existing DIP
implementation.

Closes tscircuit#371
Closes tscircuit#180
Comment on lines +1 to +44
import { test, expect } from "bun:test"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { fp } from "../src/footprinter"
import type { AnyCircuitElement } from "circuit-json"

test("pdip8 resolves to dip8", () => {
const pdipJson = fp.string("pdip8").json()
const dipJson = fp.string("dip8").json()
expect(pdipJson).toEqual(dipJson)
})

test("PDIP8 case-insensitive", () => {
const uppercaseJson = fp.string("PDIP8").json()
const lowercaseJson = fp.string("pdip8").json()
expect(uppercaseJson).toEqual(lowercaseJson)
})

test("pdip8 generates 8 plated holes", () => {
const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[]
const platedHoles = circuitJson.filter(
(el) => el.type === "pcb_plated_hole",
)
expect(platedHoles.length).toBe(8)
})

test("pdip8 svg snapshot", () => {
const circuitJson = fp.string("pdip8").circuitJson() as AnyCircuitElement[]
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "pdip8")
})

test("spdip28 resolves to dip28", () => {
const spdipJson = fp.string("spdip28").json()
const dipJson = fp.string("dip28").json()
expect(spdipJson).toEqual(dipJson)
})

test("spdip28 generates 28 plated holes", () => {
const circuitJson = fp.string("spdip28").circuitJson() as AnyCircuitElement[]
const platedHoles = circuitJson.filter(
(el) => el.type === "pcb_plated_hole",
)
expect(platedHoles.length).toBe(28)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file contains 6 test() functions (lines 6, 12, 18, 26, 32, and 38), which violates the rule that a *.test.ts file may have AT MOST one test(...). After the first test, the user should split into multiple numbered files. To fix this, split the tests into separate files like pdip1.test.ts, pdip2.test.ts, pdip3.test.ts, pdip4.test.ts, pdip5.test.ts, and pdip6.test.ts, with each file containing only one test() function.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pdio and spdip arent aliases afaik

@seveibar
Copy link
Contributor

Ie they are separate fns

PDIP (Plastic DIP) and SPDIP (Shrink Plastic DIP) are standard DIP
package variants. Implemented as separate functions in src/fn/ that
delegate to the existing DIP implementation with appropriate defaults:

- PDIP: 2.54mm pitch, 300mil row width (standard DIP dimensions)
- SPDIP: 1.778mm pitch, 300mil row width (shrink pitch variant)

Closes tscircuit#371
Closes tscircuit#180
@iprevail-io
Copy link
Author

Updated — PDIP and SPDIP are now implemented as separate footprint functions (src/fn/pdip.ts and src/fn/spdip.ts) instead of regex aliases. Each has its own definition using extendDipDef(), matching the existing pattern (e.g. sop8, ms012). Added type definitions in footprinter.ts and tests for both variants.

@iprevail-io iprevail-io requested a review from seveibar March 21, 2026 17:58
@iprevail-io iprevail-io changed the title feat: add PDIP and SPDIP aliases for DIP footprint feat: add PDIP and SPDIP as separate footprint functions Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants