Skip to content

fix: CLI tsx conversion crashes — pass { rawEasy } to convertRawEasyToTsx - #401

Open
chayan-1906 wants to merge 3 commits into
tscircuit:mainfrom
chayan-1906:fix-cli-tsx-conversion
Open

fix: CLI tsx conversion crashes — pass { rawEasy } to convertRawEasyToTsx#401
chayan-1906 wants to merge 3 commits into
tscircuit:mainfrom
chayan-1906:fix-cli-tsx-conversion

Conversation

@chayan-1906

Copy link
Copy Markdown

fixes #400

Problem

easyeda convert -i <part> -o <file>.tsx crashed for every part number — even the README's own example:

easyeda convert -i C46749 -o C46749.tsx
Error: [
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "undefined",
    "path": [],
    "message": "Required"
  }
]

Fix

convertEasyEdaJsonToVariousFormats passed the raw EasyEDA JSON directly to convertRawEasyToTsx, which expects { rawEasy } — so rawEasy destructured to undefined and EasyEdaJsonSchema.parse threw. One-line change:

- const tsComp = await convertRawEasyToTsx(rawEasyEdaJson)
+ const tsComp = await convertRawEasyToTsx({ rawEasy: rawEasyEdaJson })

TypeScript can't catch this because the input can come from JSON.parse (typed any).

Also updated the two README library examples that still showed the old convertRawEasyEdaToTs(rawEasyJson) calling convention.

Testing

  • New regression test tests/convert-easyeda-json-to-various-formats.test.ts: converts a local tests/assets/C46749.raweasy.json to tsx (no network needed). It fails on current main with the exact ZodError above and passes with this fix.
  • bun test — suite green (the only failures ever observed were pre-existing 5s network timeouts in convert-to-ts tests, which also occur on clean main and pass when run in isolation)
  • bun run format:check
  • bunx tsc --noEmit
  • bun run build
  • Verified the real CLI end-to-end after the fix: C46749, C2879853, C9900014805 and C5360621 all produce valid .tsx output.

🤖 Generated with Claude Code

https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4

chayan-1906 and others added 3 commits July 2, 2026 14:15
convertRawEasyToTsx expects an object with a rawEasy property, but the
CLI passed the raw EasyEDA JSON directly, so rawEasy destructured to
undefined and EasyEdaJsonSchema.parse crashed for every part when
converting to .tsx/.ts output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4
Exercises the .tsx output path of convertEasyEdaJsonToVariousFormats
using a local test asset (no network). Fails on main with the
"expected object, received undefined" ZodError and passes with the fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4
The library examples still showed the old direct-argument call, which
fails the same way as the CLI did.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4
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.

CLI convert -o <file>.tsx crashes for every part — convertRawEasyToTsx called with wrong argument shape

1 participant