Skip to content

Conversation

@fbbdev
Copy link
Collaborator

@fbbdev fbbdev commented Feb 2, 2026

Description

Fixes an issue that was preventing proper processing of alias dependencies, leading to missing package names and imports in binding generator output. Adds a new test case to prevent future regressions.

Fixes #4578

Many thanks to @MikeLINGxZ for reporting the issue and @ddmoney420 for debugging it.

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Regenerated + type-checked test data and inspected the diff.

  • Windows
  • macOS
  • Linux

Test Configuration

 Wails (v3.0.0-dev)  Wails Doctor 
                                                                                
# System 

┌──────────────────────────────────────────────────┐
| Name          | MacOS                            |
| Version       | 15.7.3                           |
| ID            | 24G419                           |
| Branding      | Sequoia                          |
| Platform      | darwin                           |
| Architecture  | arm64                            |
| Apple Silicon | true                             |
| CPU           | Apple M4 Max                     |
| CPU 1         | Apple M4 Max                     |
| CPU 2         | Apple M4 Max                     |
| GPU           | 32 cores, Metal Support: Metal 3 |
| Memory        | 36 GB                            |
└──────────────────────────────────────────────────┘

# Build Environment 

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.25.6                                 |
| Revision     | 9d6c03ca57cc734703977d113ce6897daf8c9b0e |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOARCH       | arm64                                    |
| GOARM64      | v8.0                                     |
| GOOS         | darwin                                   |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | 9d6c03ca57cc734703977d113ce6897daf8c9b0e |
| vcs.time     | 2026-02-01T03:10:36Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies 

┌────────────────────────────────────────────────────────────────────────┐
| *NSIS           | Not Installed. Install with `brew install makensis`. |
| Xcode cli tools | 2410                                                 |
| npm             | 11.6.2                                               |
| docker          | *Not installed (optional - for cross-compilation)    |
|                                                                        |
└─────────────────────── * - Optional Dependency ────────────────────────┘

# Checking for issues 

 SUCCESS  No issues found

# Diagnosis 

 SUCCESS  Your system is ready for Wails development!

Need documentation? Run: wails3 docs
 ♥   If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Added a SubStruct model in a subpackage and exported it across JS/TS outputs.
    • Introduced a SubPackageAlias type and exposed it in index re-exports.
    • Added SPA field to AliasGroup and a new GetButSubPackageAlias API that returns the alias type.
  • Bug Fixes

    • Fixed binding generation for cross-package type aliases, improving multi-package type support in generated bindings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

Refactors cycle-detection to use native map[*types.TypeName]bool in the import collector and create renderer, fixes binding generation for cross-package type aliases, adds testcases demonstrating a SubPackageAlias and SubStruct, and updates generated JS/TS outputs and the changelog.

Changes

Cohort / File(s) Summary
Core cycle-detection refactor
v3/internal/generator/collect/imports.go, v3/internal/generator/render/create.go
Replace typeutil.Map with map[*types.TypeName]bool for visited tracking; adjust cycle checks to operate on TypeName objects (obj) and propagate the new map-based visited parameter.
Testcases (source)
v3/internal/generator/testcases/aliases/main.go, v3/internal/generator/testcases/aliases/subpkg/subpkg.go
Add SubPackageAlias alias, SPA field on AliasGroup, a SubStruct type in subpkg, and a new GetButSubPackageAlias service method to exercise cross-package alias handling.
Generated JS outputs
v3/internal/generator/testdata/output/lang=JS/.../testcases/aliases/* (multiple files across UseInterfaces/UseNames variants)
Add subpkg imports/exports and SubPackageAlias typedefs; extend AliasGroup with SPA handling; add GetButSubPackageAlias and wire new create helpers (e.g., $$createType9) that reference subpkg.SubStruct.createFrom; adjust nested type creation flows accordingly.
Generated TS outputs
v3/internal/generator/testdata/output/lang=TS/.../testcases/aliases/* (multiple files across UseInterfaces/UseNames variants)
Mirror JS changes in TypeScript: add SubPackageAlias exports/types, SPA in interfaces/classes, re-exports for subpkg.SubStruct, new GetButSubPackageAlias functions, and updated createFrom wiring using subpackage factories.
Changelog
v3/UNRELEASED_CHANGELOG.md
Add entry: "Fix binding generation for cross-package type aliases (#4578)".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #4068 — Touches generator alias/testcase files and similar alias-related generated outputs; overlaps with this PR's test and output changes.
  • #4045 — Modifies cycle-detection and import/alias handling in the generator; directly related to the same files adjusted here.
  • #4001 — Changes import/typedef handling and cycle-tracking in the generator; related at the code-level to alias generation fixes.

Suggested labels

Bug, Documentation, v3, v3-alpha, size:XS, lgtm

Poem

🐇 I hopped through packages near and far,
Found aliases tangled like yarn on a star,
Swapped in maps, gave cycles a shove,
Now SubStruct and SPA fit like a glove,
Hooray — bindings fixed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: binding generation for cross-package type aliases, directly addressing the core issue in the changeset.
Description check ✅ Passed The description is comprehensive and mostly follows the template with issue reference (#4578), type of change selected (bug fix), testing performed (macOS with test data regeneration), and all major checklist items completed including changelog updates and test additions.
Linked Issues check ✅ Passed The PR fully addresses issue #4578 by fixing namespace reference generation for cross-package type aliases. The code changes replace typeutil.Map with native maps for cycle detection and ensure proper handling of TypeName objects to enable correct package-scoped namespace generation in TypeScript bindings.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the cross-package type alias binding generation issue. The core logic changes (imports.go and create.go), test case additions, and generated output updates all serve the singular objective of resolving #4578.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@fbbdev
Copy link
Collaborator Author

fbbdev commented Feb 2, 2026

@ddmoney420 could you please test whether this solves the issue for you?

@fbbdev fbbdev changed the title fix(v3): binding generation for cross-package type aliases fix(v3/generator): binding generation for cross-package type aliases Feb 2, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
44.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

Amazing! ❤️

@leaanthony leaanthony merged commit 801acd0 into wailsapp:v3-alpha Feb 3, 2026
61 of 63 checks passed
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.

2 participants