obviously I am trying to get facebooks async init working. Doing it, I need to create a function on object window called “fbAsyncInit”. I am having simillar problem, when writing web workers, because there I want to use self.postMessage but self is once again having as its interface interface Window.
However I try to do it, the typscript compiler is not happy with me adding a field to window which is not specified in Window interface.
I tried to do it like this at first:
interface WindowFB extends Window {
fbAsyncInit: ()=>any;
}
declare var window: WindowFB;
that didn’t help so I tried some other things and managed to get type checker happy, but it seems like it is just bugged(because for the solutions it is not happy 100%).
Does anybody know what the right solution for this might be?
The ‘Window’ interface is open. You can just write:
Due to some bugs around lib.d.ts, this won’t quite work in the TypeScript Playground, but the command-line compiler should be able to accept this.