wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Typescript definition not generated for string enums

Open Vlad-Shcherbina opened this issue 5 years ago • 1 comments

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

Vlad-Shcherbina avatar May 25 '20 12:05 Vlad-Shcherbina