Skip to content

fix(v2): mark collection interface fields nullable#5783

Open
Sushanth012 wants to merge 1 commit into
wailsapp:masterfrom
Sushanth012:fix/v2-nullable-collection-interfaces
Open

fix(v2): mark collection interface fields nullable#5783
Sushanth012 wants to merge 1 commit into
wailsapp:masterfrom
Sushanth012:fix/v2-nullable-collection-interfaces

Conversation

@Sushanth012

@Sushanth012 Sushanth012 commented Jul 15, 2026

Copy link
Copy Markdown

Summary

  • mark v2 TypeScript interface fields for Go slices and maps as | null to match JSON serialization
  • keep fixed-length Go arrays and class output unchanged
  • add regression coverage for primitive slices, struct slices, maps, and arrays
  • document the fix in the v2 changelog

Testing

  • go test ./internal/binding/... -count=1
  • go vet ./internal/typescriptify ./internal/binding/...

Fixes #3588

Summary by CodeRabbit

  • Bug Fixes

    • Corrected generated TypeScript interfaces so nullable slice and map fields include | null.
    • Preserved appropriate array typing for fixed-length arrays and nested object collections.
  • Documentation

    • Added an unreleased changelog entry describing the nullable collection type fix.

@github-actions github-actions Bot added Documentation Improvements or additions to documentation v2-only bindings labels Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b0b98987-48fc-4f5f-a7de-976021729558

📥 Commits

Reviewing files that changed from the base of the PR and between f681ae8 and db46498.

📒 Files selected for processing (4)
  • v2/internal/binding/binding_test/binding_test.go
  • v2/internal/binding/binding_test/binding_tsgeneration_test.go
  • v2/internal/typescriptify/typescriptify.go
  • website/src/pages/changelog.mdx

Walkthrough

TypeScript interface generation now emits | null for nullable Go map and slice fields. New binding tests cover collection types, including maps, simple slices, nested struct slices, and fixed arrays, and the changelog records the fix.

Changes

Nullable collection interface generation

Layer / File(s) Summary
Propagate collection nullability
v2/internal/typescriptify/typescriptify.go
Map and slice conversion passes nullability into field builders, which append `
Validate generated interfaces
v2/internal/binding/binding_test/*, website/src/pages/changelog.mdx
Adds nullable collection model-generation assertions and documents the v2 TypeScript interface fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: leaanthony

Poem

I’m a rabbit with types in a row,
| null makes the safe values grow.
Maps and slices now declare what they may be,
While fixed arrays stay tidy and free.
Hop through the tests—green carrots for thee!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making v2 collection interface fields nullable.
Description check ✅ Passed The description covers the summary, linked issue, and testing, but omits some template checklist and type-of-change details.
Linked Issues check ✅ Passed The code adds nullable handling for slice and map fields in interface generation and adds regression tests, matching #3588.
Out of Scope Changes check ✅ Passed The PR changes stay focused on nullable interface generation, tests, and the related changelog entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bindings Documentation Improvements or additions to documentation v2-only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typescript interface generation doesn't include null for slice or map

1 participant