I need to invoke a Blazor Wasm method from my script code, and have been successful in doing that using the code below. This works when the code is in a native JS file, but I get a compiler error (cannot find name 'DotNet') when I try to place it in a TypeScript
file. Is there some way to do this in TS?
Member
26 Points
63 Posts
Using DotNet.invokeMethodAsync in TypeScript
Jun 12, 2020 05:17 PM|CincySteve|LINK
I need to invoke a Blazor Wasm method from my script code, and have been successful in doing that using the code below. This works when the code is in a native JS file, but I get a compiler error (cannot find name 'DotNet') when I try to place it in a TypeScript file. Is there some way to do this in TS?
Thanks. Steve
All-Star
58224 Points
15670 Posts
Re: Using DotNet.invokeMethodAsync in TypeScript
Jun 12, 2020 08:04 PM|bruce (sqlwork.com)|LINK
see this thread:
https://github.com/dotnet/aspnetcore/issues/18902
Member
26 Points
63 Posts
Re: Using DotNet.invokeMethodAsync in TypeScript
Jun 13, 2020 12:04 PM|CincySteve|LINK
Thanks, Bruce. Good to know the situation.
Update: This reply from Bruce to a different question contains the answer: https://forums.asp.net/t/2168544.aspx?How+to+Pass+IndexedDB+Data+to+Blazor+using+TypeScript+During+Initialization.
Include the JSInterop interface definitions in the project as a d.ts file.