-
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
Unnecessary Typescript definitions are created for web_sys string enums #4163
Comments
Stemming from #4147. I didn't check yet, but this might justify a yank. |
I reproduced the issue and technically it is working as intended. (Sorry in advance for the long comment. I tried to make it as short as possible, but it still ended up like this.) How
|
Is there any use-case for defining string enums in TS that aren't exported? While its interesting to hash all this out, I'm unsure how to proceed right now. My plan right now is:
WDYT? |
Yes, for typing. This is the private string enum used publicly case. Or did I misunderstand your question?
I would prefer this as a temporary solution, because it means that #2153 remains fixed. Not having TS types for Thoughts? |
My understanding is that the generated TS file is only used to import it, so I don't understand what not exported types would be good for. Unfortunately I'm clueless about TS and the ecosystem, so I might be just missing something obvious.
My concern is that there other types that are exposed now that should not. E.g. private enum types are exported, maybe we don't want that. But agreed on the latter part, if everything else would be in order using |
Sorry for the confusion. My code example for "private string enum used publicly" had an error. It should have been: type UserState = "closed" | ...;
export function foo(arg: UserState); If |
No, I'm actually running on fumes here. Unfortunately, after thinking about this more, I think #4173 won't work out after all. So I will have to go ahead with the original plan and revert #4147. But please let this not discourage you from continuing to work on #2153 if you want to, I'm still happy to continue finding a solution and reviewing an implementation! |
Ah, true.
No worries, please do. I think just I'm going to make a version of #4147 that only exports the type if referenced elsewhere (in the next couple of days). This should be compatible (fixing this issue) while still resolving #2153, right? |
Sorry for causing some of our headaches and please take care of yourself. |
All good, thank you for all the contributions and all the input you have given so far! |
Describe the Bug
After updating to wasm_bindgen 0.2.94 / web_sys 0.3.71, I noticed that the generated Typescript definition file created by wasm-pack contained definitions for a bunch of string enums stemming from web_sys, e.g.
These were not there with wasm_bindgen 0.2.93.
Steps to Reproduce
Cargo.toml:
src/lib.rs
Build:
wasm-pack build --release --target web
Expected Behavior
Definitions are only generated for types that are part of my crate's interface
Actual Behavior
Definitions are generated for the
web_sys::MediaSourceReadyState
enum despite it not being part of my library at all.More string enum definitions are generated if other web_sys features are enabled
The text was updated successfully, but these errors were encountered: