Skip to content

Functions returning Result<T,E> result in incorrect typescript function output type Array #4207

@wandomPewlin

Description

@wandomPewlin

Describe the Bug

In version 0.2.95, any function returning a Result<T,E> will cause the generated typescript function to return Array (note that it's not Array<T>, just Array). The problem doesn't occur in version 0.2.93.

Steps to Reproduce

Using the code from wasm-bindgen doc

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn throwing_function() -> Result<(), JsError> {
    Err(JsError::new("message"))
}

Expected Behavior

in version 0.2.93, the generated function signature in typescript would be

export function throwing_function(a: number): void;

Actual Behavior

but in 0.2.95, it becomes.

export function throwing_function(): Array;

Additional Context

The problem doesn't seem to be JsError itself, I originally run into the problem while using serde-wasm-bindgen and the function returns Result<i32,JsValue>. The generated ts function also returns Array as output.

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