Currently, I am working on developing a WebExtension using TypeScript that will be later compiled into JavaScript.
This extension relies on one of the browser APIs offered by Firefox, specifically the extension API. An example of this is my use of the getURL() method, which is called in the following manner:
browser.extension.getURL("foo/bar.js");
However, while coding in TypeScript, an error "Cannot find name 'browser'" is thrown, preventing complete compilation of the code. I am looking for a solution to bypass this issue, ideally not just at the compile level but also during linting.
I have already attempted the following:
- Defining
browser
at the beginning asvar browser: any;
: caused issues with the API functionality. - Compiling with
--noEmit
,--noEmitOnErrors
: did not resolve the problem, and errors persist.
Do you have any suggestions or solutions to address this issue?