-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bug: structs with flattened enums produce invalid TS #43
Comments
This is unfortunately a bug :-(. The original tsify author was not keen on switching One possible consequence is an interaction with generics. Since I would welcome a PR that tested out using |
I run into an issue regarding the types generated for structs with flattened enums.
For example when I define:
the following TS gets generated:
The problem lies in the
interface Root extends RootType
statement which results in the following error being emitted bytsc
:and at least in vscode intellisense doesn't pickup the type correctly.
I couldn't find any macro attributes that would result in the correct TS output but maybe I'm missing something. Other than manually changing the TS
Root
definition to usetype
instead ofinterface
a workaround is to change the RustRoot
to an enum:which yields a working TS definition, albeit at the expense of the Rust side ergonomics:
I get the same behavior with both 0.5.4 and 27d6982.
If this is truly a bug and not a user error I can try to have a peek under the hood at some point, but that being said I don't have a ton of experience with Rust macros so it will likely take some time 😀
The text was updated successfully, but these errors were encountered: