Skip to content

TypeScript type definitions (d.ts) not available for the "Blazor" object #44942

@yugabe

Description

@yugabe

Is there an existing issue for this?

  • I have searched the existing issues

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

When initializing Blazor manually via JavaScript, the user is expected to understand the API surface of the global Blazor API based on the following article [https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-7.0](ASP.NET Core Blazor startup | Microsoft Learn)

The API itself is not very well documented in this case. First, it can be deduced the object is probably a bit different between the hosting models.

Describe the solution you'd like

A straightforward way to document would be to publish a DefinitelyTyped package for the API. This also could be referenced by the docs page mentioned above.

I think it's not a stretch to add this type to the existing @types/blazor__javascript-interop package.

Additional context

I am currently using my own type definition that I tried to figure out from the documentation page:

declare global {
    const Blazor: {
        start: (options?: {
            loadBootResource?: (
                type: 'assembly' | 'pdb' | 'dotnetjs' | 'dotnetwasm' | 'timezonedata',
                name: string,
                defaultUri: string,
                integrity: string) => string | Promise<Response> | null | undefined,
            applicationCulture?: string
        }) => Promise<void>;
    }
}

The definitions help users to find features and solutions to problems in itself, so it shouldn't be overlooked. It can also be considered to be generated (if the source is in TypeScript; I wasn't able to find it in the limited time I spent on this issue).

Possibly related: #18902

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions