Skip to content

Publish TypeScript @types packages for Blazor JavaScript Interop #18902

@ryanelian

Description

@ryanelian

Is your feature request related to a problem? Please describe.

There are methods that can be called when using Blazor JS interop: https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interop?view=aspnetcore-3.1#invoke-net-methods-from-javascript-functions

However, using these methods in the JS project can be a guessing exercise because the API is barely documented, especially when using TypeScript which requires type declarations to be defined.

Describe the solution you'd like

Example TypeScript interface declaration for Instance method call thing in Blazor JS interop:

interface dotNetHandler {
    invokeMethodAsync<T>(methodName: string, ...args): Promise<T>;
}

A new package on npm @types/blazor or @types/blazor-js-interop or something like that should be published with all type information for using Blazor JavaScript Interop

Additional context

In my experience, that window.DotNet is a mystery because invokeMethodAsync is always undefined there for some reason. So please add the TypeScript API documentation via @types packages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issueStatus: Resolvedaffected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-jsinteropThis issue is related to JSInterop in Blazorseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions