From 235bc2957e6aea095ee3e8d0857c255dc87ad683 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 30 Jan 2018 07:47:49 -0800 Subject: [PATCH] Tweak typescript option --- crates/wasm-bindgen-cli/src/bin/wasm2es6js.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/wasm-bindgen-cli/src/bin/wasm2es6js.rs b/crates/wasm-bindgen-cli/src/bin/wasm2es6js.rs index 7f56660c..8f222d19 100644 --- a/crates/wasm-bindgen-cli/src/bin/wasm2es6js.rs +++ b/crates/wasm-bindgen-cli/src/bin/wasm2es6js.rs @@ -20,14 +20,14 @@ Usage: Options: -h --help Show this screen. -o --output FILE File to place output in - --output-ts FILE File to place a typescript definition of the module to + --typescript Output a `*.d.ts` file next to the JS output --base64 Inline the wasm module using base64 encoding "; #[derive(Debug, Deserialize)] struct Args { flag_output: Option, - flag_output_ts: Option, + flag_typescript: bool, flag_base64: bool, arg_input: PathBuf, } @@ -50,9 +50,12 @@ fn main() { .generate(&wasm) .expect("failed to parse wasm"); - if let Some(ref p) = args.flag_output_ts { - File::create(p).expect("failed to create output") - .write_all(object.typescript().as_bytes()).expect("failed to write output"); + if args.flag_typescript { + if let Some(ref p) = args.flag_output { + let dst = p.with_extension("d.ts"); + File::create(dst).expect("failed to create output") + .write_all(object.typescript().as_bytes()).expect("failed to write output"); + } } let js = object.js();