Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.d.ts for _bg module #1040

Closed
likr opened this issue Nov 19, 2018 · 2 comments
Closed

.d.ts for _bg module #1040

likr opened this issue Nov 19, 2018 · 2 comments

Comments

@likr
Copy link

likr commented Nov 19, 2018

I'm trying to access wasm memory from TypeScript like this example.
https://rustwasm.github.io/wasm-bindgen/reference/types/pointers.html

But, the TypeScript compiler shows an error because the type definition for _bg module does not exist.

Currently, I manually added following .d.ts file to avoid the error.
(@types/webassembly-js-api is needed.)

import 'webassembly-js-api';

export var memory : WebAssembly.Memory;

I think it is better to automatically generate .d.ts file for _bg module.
Or, is there any other way to solve this?

@alexcrichton
Copy link
Contributor

Oops yeah I forgot about importing memory! Definitely something we should emit .d.ts files for!

We could also go ahead and emit a .d.ts file for the entire wasm module, and it would be pretty easy to do so as we've got the types of all the exports already!

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Nov 27, 2018
This generates a `*.d.ts` file for the wasm file that wasm-bindgen emits
whenever typescript is enable *in addition* to the `*.d.ts` file that
already exists for the JS shim.

Closes rustwasm#1040
@likr
Copy link
Author

likr commented Nov 28, 2018

Works fine. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants