I'm using Reactjs and typescript for my app, and I'm trying to add RocketChat Livechat using some script which is provided by RocketChat. I added my script to typescript file for some conditional base display to the users, but it's showing some error (TS2339: Property 'RocketChat' does not exist on type 'Window'.) which I unable to solve.
I tried to add RocketChat Property in Window object but not working.
Here is the code which is provided by RocketChat:
(function(w, d, s, u) {
w.RocketChat = function(c) { w.RocketChat._.push(c) }; w.RocketChat._ = []; w.RocketChat.url = u;
var h = d.getElementsByTagName(s)[0], j = d.createElement(s);
j.async = true; j.src = '/assets/rocketchat-livechat.min.js?_=xxxxxxxxx';
h.parentNode.insertBefore(j, h);
})(window, document, 'script', '/chat/livechat');
I added custom typings\custom-typings.d.ts file and I added below code, and it's working.
interface Window {
RocketChat: any
}