The message indicates that the expression in TypeScript is not callable because none of the constituents of type 'ExportValue' can be called. This issue specifically pertains to the Web

Encountered an issue while running the following code in index.ts using Deno:

const wasm = await Deno.readFile("./wasm_test/pkg/wasm_test_bg.wasm");
const wasmModule = new WebAssembly.Module(wasm);
const wasmInstance = new WebAssembly.Instance(wasmModule);
const wasmTest = wasmInstance.exports;
wasmTest.sum(1, 3); // Error

Error: This expression is not callable. No constituent of type 'ExportValue' is callable.

When attempting to call sum, an error is thrown instead of returning the expected result of 4. Interestingly, it works fine when run as index.js. The Rust code was compiled using wasm-pack.

Answer №1

The issue arises from the fact that the name add is unrecognized. Modify the 4th line of your code as follows:

const wasm = await Deno.readFile("./add.wasm");
const wasmModule = new WebAssembly.Module(wasm);
const wasmInstance = new WebAssembly.Instance(wasmModule);
const sum = wasmInstance.exports.sum as CallableFunction; // exports.add if you test with the below linked wasm.
console.log(sum(1, 3))

Refer to the official documentation.

I came across a wasm example for testing purposes featuring an add function here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The functionality of this code is optimal in Chrome and Firefox, yet it encounters issues in IE

Currently, I am attempting to create a jquery tooltip that will pop up when a user hovers over a link. The link in question is set to display:block style in order to cover a larger area. Surprisingly, this setup works flawlessly in Chrome and Firefox, but ...

Struggles with jquery and fixing images

I am currently working on a project where users can click on a thumbnail image to display a larger version in the main image section. $('.alternative_images a').click(function(e){ var imgSrc = $(this).attr('href'); $('.mai ...

retrieving a function value using jQuery

When utilizing a jQuery function, I encountered an issue where the returned value was 'NAN'. What could potentially be causing this problem? [CODE] var vax = ('#textbox1').val(); var newVal = calculateMB(vax,11,3.1); alert(newVal) ...

Adjust the textbox size based on the content it contains

http://jsfiddle.net/h2vMN/1/ Inside this text box is Lorem ipsum content which will be dynamically filled in the application. For the purpose of this question, it has been pre-filled. <textarea id="textarea"> Lorem ipsum dolor sit amet, consect ...

Updating choices within a div in real-time by changing the select box dynamically

I need to swap out the select box that is nested inside this div <div class="models"> <select disabled="disable"> <option>Model Name</option> </select> </div> I am attempting to target the div and manipul ...

Determine in JavaScript whether an array includes a function in its elements

Currently, I am adding anonymous functions to an array in the following manner: myArray.push(function(){ /* some unique code here */}); myArray.push(function(){ /* even more unique code here */}); Afterwards, I execute all the functions by doing while ( ...

Encountering incorrect JSON formatting even though the content is accurate

I'm encountering an error while trying to fetch the JSON. It seems to be in the wrong format. Below is the JSON data: { "favorite_page_response": "<div class=\"col-md-12 col-lg-12\">\n <div class=\"cart\ ...

jQuery can elegantly slide text to the center from the left while smoothly sliding it from the center to the right

Is there a way for me to make the text "hello" slide from the center to the right and fade out, while at the same time make the text "there" slide from the left to the center and fade in when I click a button? I'm struggling to achieve this without pl ...

What steps should be taken if a typings (or tsd) file cannot be found?

After reading through the TypeScript handbook, I realized that I couldn't find the solution to my problem. What are my options if I'm using a library without existing typings? The first option is to create the typings file myself, but I'm ...

Issue with `rxjs/Subject.d.ts`: The class `Subject<T>` is incorrectly extending the base class `Observable<T>`

I found a sample template code in this helpful tutorial and followed these two steps to get started - npm install // everything went smoothly, created node_modules folder with all dependencies npm start // encountered an error as shown below- node_mo ...

Differences Between React Prop Types and Typescript in Front-End

I'm considering incorporating TypeScript into my project. Would this render the use of prop-types in React unnecessary? With prop-types, I find myself having to manually define types, but TypeScript would eliminate this step. Am I on the right track? ...

Empty req.body object in Node.js

I came across this code snippet: const bodyParser = require("body-parser"); const express = require("express"); const app = express(); app.use(express.json()); app.use(bodyParser.json()); app.post("/api/foo", (request, response) => { let foo = { ...

Strategies for Repurposing local file.js across multiple Vue projects

I have a file called myfile.js with functions that I want to reuse in multiple vue projects, specifically within the App.vue file. Here is the file structure: -- projec1 ---- src ------ App.vue -- project2 ---- src ------ App.vue -- myfile.js Directly ...

Steps to convert a phone number into JSON format

The primary focus Upon receiving an MQTT packet, it is displayed as an ASCII array in the buffer after being printed using stringify: packet = { "cmd": "publish", "retain": true, "qos": 1, "dup& ...

The communication between Firefox and the server appears to be interrupted as it stops receiving responses after a certain number of HTTP requests. In this specific

For some reason, this strange behavior is only occurring in Firefox. It seems that after a certain amount of time, the browser starts sending OPTIONS requests without receiving any responses - no status, no headers, nothing I can identify in the debug cons ...

Retrieve the dependency version from the script located within the package.json file in TypeScript

Within my react project, I have a package.json structured as follows: "name": "@repo/packagex", "description": "package X", "version": "1.0.0", "scripts": { "build": ...

After removing an item from the component in reactJS, the immediate rendering of the dynamic component does not seem to be functioning correctly

I am currently creating a dynamic automobile inventory website from scratch using React.js, Express.js, and MongoDB. The data has been successfully loaded from the database and displayed in a tabular format on the client side. My next task is to enable use ...

Encountering issues with the functionality of the MUI Select component, causing the application to crash during

The issue has been successfully resolved I have been in the process of constructing a modal that includes a form and incorporating the MUI Select component. However, upon opening the modal, the application encounters an error; removing the Select componen ...

What steps should I take to address this particular issue in react native?

OOPS: The build did not go as planned! What went wrong: Could not access settings generic class cache for settings file 'C:\Users\subug\OneDrive\Desktop\React CLI Project\FirstProject\android ...

Challenges of redirecting payments through SSLCommerz

I'm encountering an issue with my code. After making a payment, it redirects to this URL: http://localhost:5173/order/$%7Border._id%7D' order?.\_id is not undefined. However, the page displays an error message stating that the site can' ...