Skip to content

Add a way to get constructor of any imported type as a value #1406

@RReverser

Description

@RReverser

Motivation

From #1403 which added Object::constructor property:

but the problem is that you can't do comparisons like any_value.constructor() == Array::constructor_as_a_function_or_something_like_that() because there is no method to get a constructor of a statically defined type.

These comparisons could be useful when one wants to check if particular value has particular type's constructor.

Proposed Solution

Add something like wasm_bindgen::get_constructor<T>() -> JsValue that could be used on any imported type to get it as an actual value (the constructor itself).

Alternatives

Statically generate some method on each imported type?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions