mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Merge pull request #1008 from henriiik/optional-typescript-return-values
update typescript generation to reflect that Option<T> can be undefined
This commit is contained in:
commit
3c31a32d51
@ -495,7 +495,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
|
|
||||||
if optional {
|
if optional {
|
||||||
if ty.is_wasm_native() {
|
if ty.is_wasm_native() {
|
||||||
self.ret_ty = "number".to_string();
|
self.ret_ty = "number | undefined".to_string();
|
||||||
self.cx.expose_global_argument_ptr()?;
|
self.cx.expose_global_argument_ptr()?;
|
||||||
self.cx.expose_uint32_memory();
|
self.cx.expose_uint32_memory();
|
||||||
match ty {
|
match ty {
|
||||||
@ -533,7 +533,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ty.is_abi_as_u32() {
|
if ty.is_abi_as_u32() {
|
||||||
self.ret_ty = "number".to_string();
|
self.ret_ty = "number | undefined".to_string();
|
||||||
self.ret_expr = "
|
self.ret_expr = "
|
||||||
const ret = RET;
|
const ret = RET;
|
||||||
return ret === 0xFFFFFF ? undefined : ret;
|
return ret === 0xFFFFFF ? undefined : ret;
|
||||||
@ -542,7 +542,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(signed) = ty.get_64() {
|
if let Some(signed) = ty.get_64() {
|
||||||
self.ret_ty = "BigInt".to_string();
|
self.ret_ty = "BigInt | undefined".to_string();
|
||||||
self.cx.expose_global_argument_ptr()?;
|
self.cx.expose_global_argument_ptr()?;
|
||||||
let f = if signed {
|
let f = if signed {
|
||||||
self.cx.expose_int64_memory();
|
self.cx.expose_int64_memory();
|
||||||
@ -567,7 +567,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
|
|
||||||
match *ty {
|
match *ty {
|
||||||
Descriptor::Boolean => {
|
Descriptor::Boolean => {
|
||||||
self.ret_ty = "boolean".to_string();
|
self.ret_ty = "boolean | undefined".to_string();
|
||||||
self.ret_expr = "
|
self.ret_expr = "
|
||||||
const ret = RET;
|
const ret = RET;
|
||||||
return ret === 0xFFFFFF ? undefined : ret !== 0;
|
return ret === 0xFFFFFF ? undefined : ret !== 0;
|
||||||
@ -575,7 +575,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
return Ok(self);
|
return Ok(self);
|
||||||
}
|
}
|
||||||
Descriptor::Char => {
|
Descriptor::Char => {
|
||||||
self.ret_ty = "string".to_string();
|
self.ret_ty = "string | undefined".to_string();
|
||||||
self.cx.expose_global_argument_ptr()?;
|
self.cx.expose_global_argument_ptr()?;
|
||||||
self.cx.expose_uint32_memory();
|
self.cx.expose_uint32_memory();
|
||||||
self.prelude("const retptr = globalArgumentPtr();");
|
self.prelude("const retptr = globalArgumentPtr();");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user