Add no_export
attribute and export all enums by default
#4301
+378
−271
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the
no_export
attribute we talked about. Enums with theno_export
attribute will not be exported in JS and TS. This makes them consistent withstruct
s that are also exported by default and provides an option to opt out.The
no_export
attribute is completely independent of the visibility of the Rust enums. E.g. an enum may bepub
and non-exported, or private and exported. To make this consistent, string enums no longer use the enum's visibility to determine whether their type is exported.Changes:
no_export
attribute.no_export
to all string enums inweb-sys
.TODO:
no_export
that are used in exported function are currently typed as non-exported TS enums in TS. This makes the exported functions with such enums are parameters a lot less useful, since they can't be invoked without either (1) TS compiler errors or (2) a type cast toany
to work around the type checker.