chat-widget-adapters icon indicating copy to clipboard operation
chat-widget-adapters copied to clipboard

Update window types

Open eluce2 opened this issue 1 year ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @livechat/[email protected] for the project I'm working on.

I noticed that you included the types for the widget in your package, but they were not applying for me in my Next.js app. I'm using version 4.9.5 of Typescript.

Here is the diff that solved my problem:

diff --git a/node_modules/@livechat/widget-core/dist/widget-core.d.ts b/node_modules/@livechat/widget-core/dist/widget-core.d.ts
index a30da32..551784c 100644
--- a/node_modules/@livechat/widget-core/dist/widget-core.d.ts
+++ b/node_modules/@livechat/widget-core/dist/widget-core.d.ts
@@ -1,4 +1,5 @@
-declare type ExtendedWindow = Window & {
+ declare global{
+ interface Window  {
     __lc: {
         license: number;
         group?: number;
@@ -21,7 +22,8 @@ declare type ExtendedWindow = Window & {
     LC_API?: {
         on_after_load?: VoidFunction;
     };
-};
+}
+ }
 declare function on(name: 'ready', handler: EventHandlers['onReady']): void;
 declare function on(name: 'new_event', handler: EventHandlers['onNewEvent']): void;
 declare function on(name: 'form_submitted', handler: EventHandlers['onFormSubmitted']): void;

This issue body was partially generated by patch-package.

eluce2 avatar Apr 28 '23 20:04 eluce2