Type aliases are not getting transformed
Bug report
When creating type alias from resource, eg:
pub struct Bar(Resource<...>);
And using that type in function, eg:
#[externref]
extern "C" {
fn imported_function() -> Bar;
}
After transformed, the imported function return type is not changed to externref, but is i32.
There is a good reason to use type alias for Resource type. Many times it is needed to implement custom drop trait for externref, to free resources which javascript object is holding (in my project is is to call "destroy()" on webgpu buffers). Custom drop trait is not possible to add to the type that crate does not own. Being able to create type alias, allows the drop being implemented for resource.
If there is some other way to add drop trait for a Resource, then this bug does not need be solved.
Thanks for submitting an issue!
Many times it is needed to implement custom drop trait for externref
This is a valid use case, but can't it be achieved by wrapping a Resource into a newtype after retrieving it from an imported function? I.e.:
pub struct Bar(Resource<Self>);
#[externref]
extern "C" {
fn create_bar() -> Resource<Bar>;
fn drop_bar(bar: &mut Resource<Bar>);
}
impl Bar {
pub fn new() -> Self {
Self(unsafe { create_bar() })
}
}
impl Drop for Bar {
fn drop(&mut self) {
unsafe { drop_bar(&mut self.0); }
}
}