Skip to content

How to get more detailed type information in .d.ts #1197

Closed
@dlesl

Description

@dlesl

Hi!
At the moment it's possible to pass pretty much anything between Rust and js as a JsValue, or using js-sys, however it would be nice to have a way to provide more detailed information in the .d.ts files.
For example, I can return an array of rust structs as Box<[JsValue]>, which in typescript becomes any[]. If I return js_sys::Promise, I get Promise<any>.

Would it be a good idea to add type parameters to the types in js-sys, so that you could return Array<SomeStruct> in rust? Of course, js arrays can contain mixed types, but that could still be represented by Array<JsValue>.

Would this be making things unnecessarily complex?

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