-
-
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
Add support for interface generation and enums #3047
Add support for interface generation and enums #3047
Conversation
@leaanthony curios about your input for that 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! Just a small question 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we should have both enum + interface tests in binding/binding_test
to make sure we're tracking this going forward.
@leaanthony will write the tests for this on weekends |
@leaanthony added some tests
As well as fixed the case, when struct contains imported enum (before it doesn't track type for it correctly) |
@leaanthony anything else that I maybe need to add it this PR? Thanks |
No, just need time to review 🙏 |
@leaanthony @stffabi I want to use enums in my project as it will be much convenient to follow contracts between frontend and backend then 🙂 I currently use |
Thanks @APshenkin 🙏 |
Description
Some engineers prefer interfaces rather than classes for typescript types. So I added option in
wails.json
to choose betweenclasses
andinterfaces
. Classes are chosen as default for backward compatibility.Also typescriptify supports providing types for enums. https://github.com/tkrajina/typescriptify-golang-structs#enums
As generation for them is sligtly different, I added
EnumBind
to App configuration like thisThis then generate proper enums in
model.ts
file, so types are not missing if you return something in structsfixes #2258
And partially solve this #2104
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor
.Test Configuration
I created some showcase here https://github.com/APshenkin/wails-open-file/tree/feature/ts-interfaces-enums
Checklist:
website/src/pages/changelog.mdx
with details of this PR