For chrome extension developed using typescript, we need a definition file called chrome.d.ts in typings folder for accessing web extension APIs like chrome.runtime.* or chrome.tabs.*.
For edge extension, developing in typescript, we need a definition file called browser.d.ts in typings folder for accessing web extension APIs like browser.runtime.*
How can we download this dependency using node package manager(npm). I added a reference to the file in my background.ts file of extension like:
/// reference path="typings/browser/browser.d.ts"
Update:
Typings are available for Firefox's browser API and its browser polyfill library.
Unfortunately, Edge's browser API is not the same as Firefox's. Edge uses callbacks while Firefox uses Promises. This may or may not change.
See:
Since you need browser.d.ts only for type conversion this solution will work
You can add:
declare var browser: any;
at the top of your file where you are using browser.runtime.