Skip to content

Invalid d.ts produced after 0.2.56 upgrade #1926

Closed
@TomCrypto

Description

@TomCrypto

Describe the Bug

After upgrading to 0.2.56, there are errors in the generated crate.d.ts (not the _bg one) that are due to invalid generated typescript.

Steps to Reproduce

  1. Use the https://github.com/rustwasm/wasm-pack-template or whatever to create a new project
  2. Insert the following test case
#[wasm_bindgen]
pub struct Foo {}

#[wasm_bindgen]
impl Foo {
    pub fn test1(&mut self) -> bool {
        true
    }

    pub fn test2(&mut self, _foo: f32) {
        return;
    }
}

Expected Behavior

The expected (and generated as of 0.2.55) d.ts looked like this:

export class Foo {
  free(): void;
/**
* @returns {boolean} 
*/
  test1(): boolean;
/**
* @param {number} _foo 
*/
  test2(_foo: number): void;
}

Actual Behavior

When using wasm-bindgen 0.2.56 instead, the following invalid typescript is generated instead:

export class Foo {
  free(): void;
/**
* @returns {bool} 
*/
  test1(): bool;
/**
* @param {number} this.ptr 
*/
  test2(this.ptr: number): void;
}

Additional Context

There might be other regressions; these are just the ones that I immediately found in my wasm project.

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