Skip to content

Cannot access type interfaces from the browser API as @types/chrome. #1213

Closed

Description

@1natsu172

The second thing is that the interface as a type cannot be inferred from the browser as you say. This one is not a package-manager dependent problem. I think it's an implementation glitch in WXT.

The workaround over here is below, and either approach should be used.

import { Runtime } from "wxt/browser";

// This types from webextension-polyfill
function handler1(params: Runtime.MessageSender) {}

// This types from @types/chrome(need install `@types/chrome`)
function handler2(params: chrome.runtime.MessageSender) {}

Originally posted by @1natsu172 in #1116 (comment)

and

Originally posted in #1116 (comment)

Activity

  1. 1natsu172 commented on Nov 26, 2024

    @1natsu172
    ContributorAuthor

    After some investigation, it seems this might be more of an issue with the upstream type definitions rather than WXT itself. Since the interfaces are defined alongside the implementation within a namespace, there is no way to re-export them.

  2. aklinker1 commented on Nov 26, 2024

    @aklinker1
    Member

    Yeah, is this just how @types/chrome works. I have a section on using its types in the docs here:

    https://wxt.dev/guide/essentials/extension-apis.html#disabling-the-polyfill

  3. added theissue type on Mar 21, 2025
  4. aklinker1 commented on Mar 28, 2025

    @aklinker1
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions