GuildOfWeavers / genSTARK

A library for generating zk-STARKs.
MIT License
142 stars 18 forks source link

Typescript compilation error: cannot find namespace 'WebAssembly' #23

Closed cwgoes closed 4 years ago

cwgoes commented 4 years ago

Thanks for the library; looks very interesting.

From a fresh Git clone, after npm install, tsc -p . fails with:

lib/Stark.ts:364:26 - error TS2304: Cannot find name 'WebAssembly'.

364             memory : new WebAssembly.Memory({
                             ~~~~~~~~~~~

lib/Stark.ts:373:28 - error TS2304: Cannot find name 'WebAssembly'.

373         const memory = new WebAssembly.Memory({ initial: initialMemory, maximum: maximumMemory });
                               ~~~~~~~~~~~

node_modules/@guildofweavers/galois/galois.d.ts:7:26 - error TS2503: Cannot find namespace 'WebAssembly'.

7         readonly memory: WebAssembly.Memory;
                           ~~~~~~~~~~~

node_modules/@guildofweavers/merkle/merkle.d.ts:22:26 - error TS2503: Cannot find namespace 'WebAssembly'.

22         readonly memory: WebAssembly.Memory;
                            ~~~~~~~~~~~

Found 8 errors.

I am running node version v12.10.0.

Any ideas? I could try a global declaration in global.d.ts or the like:

declare const WebAssembly: any

but I would have to modify the dependencies as well.

Presumably I have simply misconfigured something locally.

bobbinth commented 4 years ago

Thanks for trying it out! What you are doing should work - but 2 thoughts:

  1. What version of TypeScript do you have? I'm currently using 3.6.2 and it comes with lib.dom.d.ts file which contains the declaration for WebAssembly namespace. I'm using VS Code and in my case the file lives under ...\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\lib.dom.d.ts
  2. If you are trying to compile the project, it's better to use Gulp tasks. If you have VS Code, the task have been already configured (in the .vscode/tasks.json file). If you are using something else, you might need to install Gulp CLI (e.g. npm install --global gulp-cli).

Let me know if any of this helps. If not, we can troubleshoot further.

bobbinth commented 4 years ago

Of course, if you just want to use the library in a project - you don't need to compile it. Just pull it from NPM and use it the same way as shown in the example here.

cwgoes commented 4 years ago

I had previously been using Typescript 3.4.x, upgraded to 3.6.3 which fixed the issue, thanks.