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

JS type for enum string is not generated #4248

Closed
skanehira opened this issue Nov 4, 2024 · 2 comments
Closed

JS type for enum string is not generated #4248

skanehira opened this issue Nov 4, 2024 · 2 comments
Labels

Comments

@skanehira
Copy link

Describe the Bug

JS type for enum string is not generated.

Rust code is bellow.

use wasm_bindgen::prelude::wasm_bindgen;

#[wasm_bindgen]
pub enum MyEnum {
    One = "one",
    Two = "two",
    Three = "three",
}

#[wasm_bindgen]
pub fn get_enum() -> MyEnum {
    MyEnum::One
}

Generated *.d.ts code is bellow.

/* tslint:disable */
/* eslint-disable */
/**
 * @returns {any}
 */
export function get_enum(): any;

Steps to Reproduce

  1. git clone https://github.com/skanehira/rust-wasm-bindgen-example
  2. make build

Expected Behavior

enum string should be

enum MyEnum {
    One = "one",
    Two = "two",
    Three = "three",
}

Actual Behavior

enum string always be any.

Additional Context

@skanehira skanehira added the bug label Nov 4, 2024
@RunDevelopment
Copy link
Contributor

Duplicate of #2153.

Also, the next release will include #4180, so the .d.ts will then look like this:

/* tslint:disable */
/* eslint-disable */
type MyEnum = "one" | "two" | "three";
export function get_enum(): MyEnum;

@skanehira
Copy link
Author

@RunDevelopment Oh, I got it.
Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants