fix(v2): generate nested TS types for embedded structs with named JSON tags#5221
fix(v2): generate nested TS types for embedded structs with named JSON tags#5221leaanthony wants to merge 1 commit intomasterfrom
Conversation
…N tags When a Go struct has an embedded (anonymous) struct field with a named JSON tag (e.g. TimeLimitDef `json:"timeLimitDef"`), Go's JSON encoder produces a nested object. But the TS binding generator was incorrectly flattening these fields into the parent class, causing deserialization failures. Fix in two places: - deepFields() in typescriptify.go: check for named JSON tags before flattening embedded structs; treat named-tag embeds as regular fields - AddStructToGenerateTS() in binding.go: allow anonymous fields with named JSON tags through for struct registration Fixes #4117
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 PR Triage Review ✅ Accepted Generates nested TS types for embedded structs with named JSON tags (v2 bindings). Improves TypeScript type safety. Platform: All (v2, bindings) Next Steps: Dispatching for testing on all platforms. Reviewed by Wails PR Reviewer Bot |
Summary
TimeLimitDef \json:"timeLimitDef"`` would be flattened into the parent TS class, but Go's JSON encoder produces a nested object — causing deserialization mismatchesdeepFields()intypescriptify.go: checks for named JSON tags before flattening embedded structsAddStructToGenerateTS()inbinding.go: allows anonymous fields with named JSON tags through for struct type registrationTest plan
binding_named_embedded_struct_test.goverifies thatStructWithNamedEmbeddedStructgenerates:InnerStructandAppInfoTS classestimeLimitDef: InnerStruct,application: AppInfo) in the parent classanyas before)Fixes #4117