Skip to content

Typescript definition not generated for string enums #2153

Open
@Vlad-Shcherbina

Description

@Vlad-Shcherbina

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions