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

enums not exported? #83

Open
lwansbrough opened this issue Feb 21, 2024 · 3 comments
Open

enums not exported? #83

lwansbrough opened this issue Feb 21, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@lwansbrough
Copy link

I'm getting the error source.js:2:43 SyntaxError: ambiguous indirect export: MyEnum when I try to import my enum like: import { MyEnum } from 'my_package:my_world/my_module' -- I see in debug mode that none of the enums appear to be exported.

@guybedford
Copy link
Collaborator

In JavaScript we don't export types currently - instead they are replicated by structure. So an enum is just a union of kebab case strings.

Introducing runtime type imports is tracking in bytecodealliance/jco#235 and may be introduced in the future.

@lwansbrough
Copy link
Author

Yeah I think it's important. I've got a ton of enums specified in wit files. Other guest code (ie. Rust) has access to them, so I think it makes sense that JS guest code would too. Otherwise the guest would have to replicate them so they can be passed as data. I'll keep an eye on the other issue, thanks.

@guybedford
Copy link
Collaborator

Right now it's easy enough to use them as just strings, but yes we are moving in the direction of runtime types.

@guybedford guybedford added the enhancement New feature or request label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants