livechat / chat-widget-adapters

This project contains a set of libraries for adapting LiveChat Chat Widget with certain frontend frameworks
https://developers.livechat.com
MIT License
24 stars 8 forks source link

Update window types #75

Open eluce2 opened 1 year ago

eluce2 commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @livechat/widget-core@1.3.0 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.