Closed zzorba closed 1 week ago
This snippet of rust will reproduce the problem in the typescript file:
#[derive(uniffi::Enum, Clone, Debug)]
pub enum InnerType {
Foo,
Bar,
}
#[derive(Clone, uniffi::Enum)]
pub enum WrappingEnum {
TotallyFine,
InnerType(InnerType),
}
Argument of type 'import("/Users/daniel/filament/packages/rn-diode/src/generated/diode").InnerType' is not assignable to parameter of type 'InnerType'.ts(2345)
I'm fairly sure that this is fixed by #70
Closing, fixed by #70
Okay, so this is a bit confusing. We have a local enum:
As you can see, it has a data field that is from a different package, but it has the same name for the 'enum'. Totally legal rust code, but, when typescript interfaces get generated: 1) it does import it from matrix_sdk_ffi
But then it ends up not using it, because of type shadowing:
The constructor should be referring to the inner type, not itself.
This causes the unpacking functions to produce typescript errors, and the type checking to generally be a bit wonky here (even though it probably works, since the code is designed to access the data correctly, even if it is not legal typescript).
I think the fix here is to alias the types on import with some generated qualification of the package name, i.e.
And then when referring to the foreign type, you always use the fully qualified 'alias' name.