Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

SIGSTACKFAULT
Copy link

I got the ADHD urge at like midnight to half-finish writing this.

@daxpedda
Copy link
Collaborator

daxpedda commented Nov 9, 2023

Thank you, it's appreciated!
Happy to review it when it's ready.

@SIGSTACKFAULT SIGSTACKFAULT marked this pull request as ready for review November 20, 2023 03:53
@SIGSTACKFAULT
Copy link
Author

Didn't touch anything near where clippy is complaining and not sure what you would like me to do.

Copy link
Collaborator

@daxpedda daxpedda left a 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)

Copy link
Collaborator

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.

Copy link
Author

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

guide/src/reference/types/enum.md Outdated Show resolved Hide resolved
Comment on lines +21 to +23
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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Author

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.

Copy link
Author

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. -->
Copy link
Collaborator

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?

Comment on lines +69 to +71

// no types generated for StringEnum (yet) :(
// see the note above
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// no types generated for StringEnum (yet) :(
// see the note above

I don't think this is necessary given the above note.

Copy link
Author

@SIGSTACKFAULT SIGSTACKFAULT Nov 20, 2023

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
@daxpedda daxpedda added the waiting for author Waiting for author to respond label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for author Waiting for author to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants