Skip to content

Commit 6540a2d

Browse files
authored
Flatten generated TypeScript definitions (#1872)
BREAKING: Generated TypeScript definitions for WebAssembly modules are now flat, that is do not `export default ASModule` anymore, but the module members directly, with the `ASModule` namespace removed.
1 parent e3d5631 commit 6540a2d

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/definitions.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -605,33 +605,28 @@ export class TSDBuilder extends ExportsWalker {
605605
build(): string {
606606
var sb = this.sb;
607607
var isWasm64 = this.program.options.isWasm64;
608-
sb.push("declare module ASModule {\n");
609-
sb.push(" type i8 = number;\n");
610-
sb.push(" type i16 = number;\n");
611-
sb.push(" type i32 = number;\n");
612-
sb.push(" type i64 = bigint;\n");
608+
sb.push("type i8 = number;\n");
609+
sb.push("type i16 = number;\n");
610+
sb.push("type i32 = number;\n");
611+
sb.push("type i64 = bigint;\n");
613612
if (isWasm64) {
614-
sb.push(" type isize = bigint;\n");
613+
sb.push("type isize = bigint;\n");
615614
} else {
616-
sb.push(" type isize = number;\n");
615+
sb.push("type isize = number;\n");
617616
}
618-
sb.push(" type u8 = number;\n");
619-
sb.push(" type u16 = number;\n");
620-
sb.push(" type u32 = number;\n");
621-
sb.push(" type u64 = bigint;\n");
617+
sb.push("type u8 = number;\n");
618+
sb.push("type u16 = number;\n");
619+
sb.push("type u32 = number;\n");
620+
sb.push("type u64 = bigint;\n");
622621
if (isWasm64) {
623-
sb.push(" type usize = bigint;\n");
622+
sb.push("type usize = bigint;\n");
624623
} else {
625-
sb.push(" type usize = number;\n");
624+
sb.push("type usize = number;\n");
626625
}
627-
sb.push(" type f32 = number;\n");
628-
sb.push(" type f64 = number;\n");
629-
sb.push(" type bool = boolean | number;\n");
630-
++this.indentLevel;
626+
sb.push("type f32 = number;\n");
627+
sb.push("type f64 = number;\n");
628+
sb.push("type bool = boolean | number;\n");
631629
this.walk();
632-
--this.indentLevel;
633-
sb.push("}\n");
634-
sb.push("export default ASModule;\n");
635630
return this.sb.join("");
636631
}
637632
}

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ export * from "./program";
299299
export * from "./resolver";
300300
export * from "./tokenizer";
301301
export * from "./types";
302-
// TODO: When vTables are pulled, perhaps it would be better to extend an ASTWalker
303302
export * from "./extra/ast";
304303
import * as util from "./util/index";
305304
export { util };
306-
307-
// TODO: compat with 0.9, remove with 0.10
308-
export * from "./util/index";

0 commit comments

Comments
 (0)