In my current project, I am working with scripts from Google and Facebook (as well as other external scripts like Intercom) in TypeScript by loading them through a script tag. However, I have encountered issues with most of them because I do not have access to their types for importing and using.
For instance, when working with Facebook, I installed the package @types/facebook-js-sdk
from DefinitelyTyped. This allowed me to see the type of window.FB
since it is declared in the namespace from the types package. But I am unable to import or use any type to define window.FB
when passing it to another piece of code, as shown below:
// window.FB is typed here
const fb = new Facebook(window.FB)
class Facebook {
// How can I type fb here?
constructor(fb) {
this.fb = fb
}
Is there a way for me to utilize the namespace to obtain types, or do I need to write the types myself in this scenario? I am open to suggestions!