-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 page to guide about enums #3693
base: main
Are you sure you want to change the base?
Conversation
for those who didn't read the prose
Thank you, it's appreciated! |
Didn't touch anything near where clippy is complaining and not sure what you would like me to do. |
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.
Thank you for doing this!
@@ -32,6 +32,7 @@ | |||
- [Wasm Audio Worklet](./examples/wasm-audio-worklet.md) | |||
- [web-sys: A TODO MVC App](./examples/todomvc.md) | |||
- [Reference](./reference/index.md) | |||
|
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.
Why add the spaces here?
Seems inconsistent with the rest.
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.
idk vscode auto-formatter just doing whatever it wants
Unfortunately, string enums don't fully work yet; no TypeScript is generated for the enum itself and functions using them accept or return `any`. | ||
They work correctly, it's just there's no type hints. | ||
See [Issue #3057](https://github.com/rustwasm/wasm-bindgen/issues/3057) |
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.
Unfortunately, string enums don't fully work yet; no TypeScript is generated for the enum itself and functions using them accept or return `any`. | |
They work correctly, it's just there's no type hints. | |
See [Issue #3057](https://github.com/rustwasm/wasm-bindgen/issues/3057) | |
Note that string enums currently don't generate a type and instead use `any`. |
Let's keep the language neutral like in the rest of the documentation.
Also I don't believe we link to issues in the rest of the documentation as well.
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.
I decided to link it so it doesn't go out of date. i agree on the wording change.
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.
like if string enums get fixed and the documentation doesn't get updated, hopefully someone will open the issue, see that it's completed, and realize "oh, the documentation must be outdated"
|
||
The generated TypeScript declarations for the above: | ||
|
||
<!-- remember to keep this up to date! copy enum.rs (above) into the lib.rs file of a new wasm-bindgen crate; use `wasm-pack build`; then copy pkg/testcrate.d.ts. also ran it through a formatter. --> |
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.
To keep this consistent in the future: is the formatter really necessary?
|
||
// no types generated for StringEnum (yet) :( | ||
// see the note above |
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.
// no types generated for StringEnum (yet) :( | |
// see the note above |
I don't think this is necessary given the above note.
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.
I worry probably too much about someone scrolling past the prose and just reading the examples
(because i would do that exact thing)
since 'enum' is reserved by rust and you can't name a module 'enum.rs'
not sure why i did that tbh
I got the ADHD urge at like midnight to half-finish writing this.