Open bes opened 7 months ago
@bes Yes, I would be open to a PR on https://github.com/siefkenj/tsify Please make your PR to the next
branch.
Curiously, there is also a third mitigation:
codegen-units = 1
When compiling in release mode, the bug does not appear, which made me interested to find out why. I tried compiling dev mode with codegen-units = 1
which also made the TypeScript interface show up.
I believe we just encountered this -- seems to still be present.
Bug
Sometimes tsify won't generate a TypeScript interface.
How to reproduce
Specifically, under these circumstances:
Given a crate that has exactly one type that has a Tsify derive, and
into_wasm_abi
but NOTfrom_wasm_abi
:crates/somecrate/lib.rs
AND the type does not appear in a direct return value (but it does appear in an indirect return value)
my_wasm_lib/lib.rs
Then there will be no
interface ExampleType
in the resulting xxx.d.ts file.Mitigation
However, this can be mitigated by one or more of the following:
Let the type appear as a direct return type
This is solution is unfortunate, because I have no use for such a method.
Let the type use
from_wasm_abi
This solution is unfortunate, because I have no use for
from_wasm_abi
andserde::Deserialize
which just add bloat.@siefkenj I got a tip from @cwfitzgerald that you have a new fork with recent fixes, would you be open to enabling issues on your fork to get stuffed fixed there?