At the moment, the functions that wasm-bindgen exports are not typesafe: https://github.com/mars-protocol/rover/blob/master/scripts/health/pkg-web/index.d.ts#L4-L20. Due to javascript serialization, it renders the arguments and return value as any. This breaks the tight coupling of the rust code to typescript. Over time, this will allow bugs to slip in unnoticed.
This PR utilizes a library called Tsify that is designed to be an attribute where you can derive what is needed for the wasm_abi. This means the exported functions can use normal structs and the types exported are no longer anys! Frontend gets strong typing and breaking code guarantees frontend will know.
At the moment, the functions that
wasm-bindgen
exports are not typesafe: https://github.com/mars-protocol/rover/blob/master/scripts/health/pkg-web/index.d.ts#L4-L20. Due to javascript serialization, it renders the arguments and return value asany
. This breaks the tight coupling of the rust code to typescript. Over time, this will allow bugs to slip in unnoticed.This PR utilizes a library called
Tsify
that is designed to be an attribute where you can derive what is needed for the wasm_abi. This means the exported functions can use normal structs and the types exported are no longerany
s! Frontend gets strong typing and breaking code guarantees frontend will know.