I'm new to .NetCore Blazor and trying to convert ExampleJsInterop JavaScript code to TypeScript.
I have a problem with converting the code below:
window.exampleJsFunctions = {
showPrompt: function (text) {
return prompt(text, 'Type your name here');
},
displayWelcome: function (welcomeMessage) {
document.getElementById('welcome').innerText = welcomeMessage;
},
returnArrayAsyncJs: function () {
DotNet.invokeMethodAsync('BlazorSample', 'ReturnArrayAsync')
.then(data => {
data.push(4);
console.log(data);
});
},
sayHello: function (dotnetHelper) {
return dotnetHelper.invokeMethodAsync('SayHello')
.then(r => console.log(r));
}
};
Well, of course, there is no problem to convert the first two functions and the last one, but I can not convert the 3rd function since the DotNet is not valid on TypeScript:
returnArrayAsyncJs: function () {
DotNet.invokeMethodAsync('BlazorSample', 'ReturnArrayAsync')
.then(data => {
data.push(4);
console.log(data);
});
}
My question is first of all, how can I convert this JS function to TS. and also that would be helpful if someone helps me to understand where this DotNet comes from.
Thanks in advance.
