Skip to content

Typescript enum definitions are not used in function signatures #2154

Closed
@Vlad-Shcherbina

Description

@Vlad-Shcherbina

To reproduce

  1. Run wasm-bindgen --target web on the wasm generated from the following library:
    use wasm_bindgen::prelude::*;
    
    #[wasm_bindgen]
    pub enum Hand {
        Left = 0,
        Righ = 1,
    }
    
    #[wasm_bindgen]
    pub fn f(h: Hand) -> Hand { h }
  2. Inspect generated .d.ts

Expected result

export enum Hand {
  Left,
  Righ,
}

export function f(h: Hand): Hand;

Actual result

export enum Hand {
  Left,
  Righ,
}

export function f(h: number): number;

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