Skip to content

fix: pass rawEasy object shape to convertRawEasyToTsx in CLI convert (#400) - #414

Open
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/cli-tsx-convert-400
Open

fix: pass rawEasy object shape to convertRawEasyToTsx in CLI convert (#400)#414
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/cli-tsx-convert-400

Conversation

@DPS0340

@DPS0340 DPS0340 commented Jul 24, 2026

Copy link
Copy Markdown

Fixes #400.

Problem

easyeda convert -i <part> -o <file>.tsx crashed for every part:

Error: [{"code":"invalid_type","expected":"object","received":"undefined","path":[],"message":"Required"}]

convertRawEasyToTsx takes { rawEasy } but the CLI convert path (lib/convert-easyeda-json-to-various-formats.ts:87) called it with the raw JSON directly, so EasyEdaJsonSchema.parse(undefined) threw. Only .tsx/.ts output was affected — other formats never hit this call.

Fix

One-line call-shape fix: convertRawEasyToTsx(rawEasyEdaJson)convertRawEasyToTsx({ rawEasy: rawEasyEdaJson }).

Verified the exact repro from the issue now works:

$ bun cli/main.ts convert -i C46749 -o C46749.tsx
[C46749] Saved TypeScript component: C46749.tsx

Verification

  • Network-free regression test converting the existing local C46749.raweasy.json asset to a tsx file (fails on main with the ZodError from the issue)
  • bunx tsc --noEmit / biome check — clean

Fixes tscircuit#400.

convertRawEasyToTsx takes { rawEasy } but the CLI convert path called it
with the raw JSON directly, so EasyEdaJsonSchema.parse(undefined) threw
for every part when outputting .tsx/.ts. Other output formats were
unaffected.

Adds a network-free regression test converting a local .raweasy.json
asset to a tsx file (fails on main with the invalid_type ZodError).
@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@seveibar mind a quick look? This is a 2-file, +40 fix.

convertRawEasyToTsx expects the raw EasyEDA object shape, but the CLI's convert path passed it the already-normalized form, so CLI conversion diverged from the library path. This passes the raw shape through as the function expects.

CI green and mergeable.

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Author

@Abse2001 @rushabhcodes @techmannih — flagging this one specifically because it's the highest impact-to-risk ratio of my three open PRs here, and it's a one-line change.

easyeda convert -i <part> -o <file>.tsx currently crashes for every part on main:

Error: [{"code":"invalid_type","expected":"object","received":"undefined","path":[],"message":"Required"}]

convertRawEasyToTsx takes { rawEasy }, but the CLI convert path passed the raw JSON positionally, so EasyEdaJsonSchema.parse(undefined) threw. The .tsx/.ts output path is the only one that calls it, which is why other formats were unaffected and this went unnoticed.

The diff is literally:

- convertRawEasyToTsx(rawEasyEdaJson)
+ convertRawEasyToTsx({ rawEasy: rawEasyEdaJson })

Two files total (the fix + a CLI regression test). Verified the exact repro from #400:

$ bun cli/main.ts convert -i C46749 -o C46749.tsx
[C46749] Saved TypeScript component: C46749.tsx

CI green, MERGEABLE / CLEAN. My other two here (#413, #415) touch different files and don't conflict with this, so this one can go in on its own.

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