Skip to content

Commit ba03cc3

Browse files
authored
Merge pull request #173 from rustwasm/ts-default
Emit `*.d.ts` file by default
2 parents 11cd661 + 89bd10f commit ba03cc3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,8 @@ some notable options are:
550550
`window.wasm_bindgen.foo`. Note that the name `wasm_bindgen` can be configured
551551
with the `--no-modules-global FOO` flag.
552552

553-
* `--typescript` - when passed a `*.d.ts` file will be generated for the
554-
generated JS file. This should allow hooking into TypeScript projects to
555-
ensure everything still typechecks.
553+
* `--no-typescript` - by default a `*.d.ts` file is generated for the generated
554+
JS file, but this flag will disable generating this TypeScript file.
556555

557556
* `--debug` - generates a bit more JS and wasm in "debug mode" to help catch
558557
programmer errors, but this output isn't intended to be shipped to production

crates/cli/src/bin/wasm-bindgen.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Options:
2828
--browser Generate output that only works in a browser
2929
--no-modules Generate output that only works in a browser (without modules)
3030
--no-modules-global VAR Name of the global variable to initialize
31-
--typescript Output a TypeScript definition file
31+
--typescript Output a TypeScript definition file (on by default)
32+
--no-typescript Don't emit a *.d.ts file
3233
--debug Include otherwise-extraneous debug checks in output
3334
--no-demangle Don't demangle Rust symbol names
3435
-V --version Print the version number of wasm-bindgen
@@ -40,6 +41,7 @@ struct Args {
4041
flag_browser: bool,
4142
flag_no_modules: bool,
4243
flag_typescript: bool,
44+
flag_no_typescript: bool,
4345
flag_out_dir: Option<PathBuf>,
4446
flag_debug: bool,
4547
flag_version: bool,
@@ -74,14 +76,16 @@ fn rmain(args: &Args) -> Result<(), Error> {
7476
None => bail!("input file expected"),
7577
};
7678

79+
let typescript = args.flag_typescript || !args.flag_no_typescript;
80+
7781
let mut b = Bindgen::new();
7882
b.input_path(input)
7983
.nodejs(args.flag_nodejs)
8084
.browser(args.flag_browser)
8185
.no_modules(args.flag_no_modules)
8286
.debug(args.flag_debug)
8387
.demangle(!args.flag_no_demangle)
84-
.typescript(args.flag_typescript);
88+
.typescript(typescript);
8589
if let Some(ref name) = args.flag_no_modules_global {
8690
b.no_modules_global(name);
8791
}

0 commit comments

Comments
 (0)