-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shouldn't we register exported field during binding ? #1721
Comments
Thanks for raising this detailed insight into the issue. We should build some tests around this for sure as it's really hard to get right all the time. I'm going to get some basic tests working around this, especially the |
Ok, I've had a quick look and created a simple example for testing TS generation. This is on the The example test is here: https://github.com/wailsapp/wails/blob/feature/ts-generation-tests/v2/internal/binding/binding_singlefield_test.go The main test runner uses it here: https://github.com/wailsapp/wails/blob/feature/ts-generation-tests/v2/internal/binding/binding_test.go This should, at the very least, allow us to reproduce bugs with the smallest examples possible. It will also allow us to debug easily and find out what the issue is. Please let me know how you get on 👍 I'll also start adding more tests here over time. EDIT: I added your example. I don't have time to debug it right now, but please take a look and confirm that is what you are seeing. Also feel free to debug it of course 😄 |
I am about to push a PR with a test that highlight the problem, would you mind to look at it ? |
Also my PR contains the fix. |
Description
I encounter a problem while generating the binding for response object with nested structure.
It appears the struct
Bs
is not added to the struct to generate for typescript, as we end up with anany
type in the TS models.I think the problem comes from these lines:
wails/v2/internal/binding/binding.go
Lines 159 to 161 in 4385fea
wails/v2/internal/binding/binding.go
Lines 171 to 173 in 4385fea
In this case, validating the condition
field.PkgPath == ""
means we found an exported field. So, we are skipping the exported fields, which, I think, is not what we want.We could use
!field.IsExported()
instead. That would be less cryptic. It has been added recently, AFAIR.To Reproduce
Not sure if this is accurate, but I think the example above could reproduce the bug.
Expected behaviour
The binding process should register nested struct in the TS models, not an
any
.Screenshots
Attempted Fixes
The following change worked for me. But I don't have the full picture so, it might not be the complete solution.
System Details
The text was updated successfully, but these errors were encountered: