rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.75k stars 1.07k forks source link

Typescript definition not generated for string enums #2153

Open Vlad-Shcherbina opened 4 years ago

Vlad-Shcherbina commented 4 years ago

To reproduce

  1. Run wasm_bindgen --target web on the wasm produced from the following library:

    use wasm_bindgen::prelude::*;
    
    #[wasm_bindgen]
    pub enum Hand {
        Left = "Left",
        Right = "Right",
    }
    
    #[wasm_bindgen]
    pub fn f(h: Hand) -> Hand { h }    
  2. Inspect generated .d.ts

Expected Behavior

export type Hand = 'Left' | 'Right';

export function f(h: Hand): Hand;

Actual Behavior

/**
* @param {any} h 
* @returns {any} 
*/
export function f(h: any): any;

Version info

wasm-bindgen 0.2.62

alexcrichton commented 4 years ago

I unfortunately don't have the time to implement a new feature like this, but a PR would be much appreciated!