Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To utilize the browser global in TypeScript, you can do the following:

  1. Declare a global variable for browser:
declare const browser: any;
  1. Use the browser global as you would normally use it in JavaScript:
browser.tabs.query({ active: true }, function(tabs) {
  console.log(tabs);
});

Note: The browser global is only available in browsers that support the WebExtensions API, such as Firefox and Chromium-based browsers (e.g. Chrome, Edge, Opera). It is not available in other browsers such as Internet Explorer.