From 620212dff815e4f79e44221b5adb6e5901896867 Mon Sep 17 00:00:00 2001 From: Paul Butler Date: Mon, 6 Jan 2020 14:17:19 -0500 Subject: [PATCH] bool -> boolean in generated TypeScript code (#1933) * bool -> boolean in generated TypeScript code * Add a test for booleans Co-authored-by: Alex Crichton --- crates/cli-support/src/js/binding.rs | 2 +- crates/typescript-tests/src/simple_fn.rs | 3 +++ crates/typescript-tests/src/simple_fn.ts | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/cli-support/src/js/binding.rs b/crates/cli-support/src/js/binding.rs index 26fb988d..c01754c0 100644 --- a/crates/cli-support/src/js/binding.rs +++ b/crates/cli-support/src/js/binding.rs @@ -875,7 +875,7 @@ fn instruction(js: &mut JsBuilder, instr: &Instruction, log_error: &mut bool) -> } Instruction::BoolFromI32 => { - js.typescript_required("bool"); + js.typescript_required("boolean"); let val = js.pop(); js.push(format!("{} !== 0", val)); } diff --git a/crates/typescript-tests/src/simple_fn.rs b/crates/typescript-tests/src/simple_fn.rs index 02006c8d..2fd727d2 100644 --- a/crates/typescript-tests/src/simple_fn.rs +++ b/crates/typescript-tests/src/simple_fn.rs @@ -2,3 +2,6 @@ use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn greet(_: &str) {} + +#[wasm_bindgen] +pub fn take_and_return_bool(_: bool) -> bool { true } diff --git a/crates/typescript-tests/src/simple_fn.ts b/crates/typescript-tests/src/simple_fn.ts index f8b91d08..62eba443 100644 --- a/crates/typescript-tests/src/simple_fn.ts +++ b/crates/typescript-tests/src/simple_fn.ts @@ -2,4 +2,5 @@ import * as wbg from '../pkg/typescript_tests'; import * as wasm from '../pkg/typescript_tests_bg'; const wbg_greet: (a: string) => void = wbg.greet; -const wasm_greet: (a: number, b: number) => void = wasm.greet; \ No newline at end of file +const wasm_greet: (a: number, b: number) => void = wasm.greet; +const take_and_return_bool: (a: boolean) => boolean = wbg.take_and_return_bool;