Skip to content

fix: parse struct references for type generation - #2552

Merged
leaanthony merged 4 commits into
wailsapp:masterfrom
dominictwlee:dominictwlee/fix-generate-regex
Apr 26, 2023
Merged

fix: parse struct references for type generation#2552
leaanthony merged 4 commits into
wailsapp:masterfrom
dominictwlee:dominictwlee/fix-generate-regex

Conversation

@dominictwlee

@dominictwlee dominictwlee commented Apr 2, 2023

Copy link
Copy Markdown
Contributor

this should fix the issues in v2.4.0 where reference type structs were breaking return types in Typescript. I think the issue stems from valueType capturing what should've been part of the valuePackage group because of ".+".

This should remedy the concerns raised in #2490 around stripping the asterix. In case we need it in the future, we could capture the asterix in a new group. I've added it to the non-capturing group for now.

@OlegGulevskyy @leaanthony let me know what you think.

I've also added a few additional cases to cover promise bindings.

closes #2489

@vercel

vercel Bot commented Apr 2, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wails-v3-docs ❌ Failed (Inspect) Apr 2, 2023 8:57am

@dominictwlee

Copy link
Copy Markdown
Contributor Author

@leaanthony bump, just following up on this to get a review, thanks!

@zllovesuki

Copy link
Copy Markdown
Contributor

👍 this looks way better

@leaanthony

Copy link
Copy Markdown
Member

👍 this looks way better

Please LMK if you test this and it fixes your issue 👍

@dominictwlee

dominictwlee commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

https://github.com/dominictwlee/test-ts-gen

@zllovesuki minimal example. clone my fork, uncomment go.mod replace, point to local wails dir and you're good to go.

TLDR;
https://github.com/dominictwlee/test-ts-gen/blob/main/app.go#L33 <= go method
https://github.com/dominictwlee/test-ts-gen/blob/main/frontend/wailsjs/go/main/App.d.ts#L5 <= generated d.ts

@leaanthony
leaanthony self-requested a review April 12, 2023 21:47
@dominictwlee

Copy link
Copy Markdown
Contributor Author

@leaanthony thanks for the review. Anything else you need from me to get this merged in?

@AlbinoDrought

Copy link
Copy Markdown
Contributor

I was updating from 2.3.1 to 2.4.1 to fix the CreateWebResourceResponse issue and experienced this Promise<any> issue, I can confirm this PR fixes it for me 🎊

@leaanthony

Copy link
Copy Markdown
Member

Thanks for this @dominictwlee. It would be good if you could update changelog.mdx under the website directory with your changes 👍

@dominictwlee
dominictwlee force-pushed the dominictwlee/fix-generate-regex branch from 889b976 to 9213f14 Compare April 25, 2023 19:25

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks so much for this 🙏

@leaanthony
leaanthony merged commit d249c22 into wailsapp:master Apr 26, 2023
@dominictwlee
dominictwlee deleted the dominictwlee/fix-generate-regex branch April 27, 2023 18:59
misitebao pushed a commit that referenced this pull request May 27, 2023
* fix: parse struct references for type generation

* chore: update changelog for typescript generation fix
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.

[v2] Binding missing types after upgrading to v2.4.0

4 participants