diff --git a/dist/index.d.ts b/dist/index.d.ts index 52fea7d..d1229d6 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -59,4 +59,11 @@ export declare function component(name: string, component?: Function): Component export declare function convertClassToAlpineConstructor(component: any): ComponentConstructor; export declare function addTitles(): void; export declare function bootstrap(): void; +declare global { + interface Window { + Alpine: Alpine; + deferLoadingAlpine: any; + AlpineComponents: any; + } +} export {}; diff --git a/package.json b/package.json index 065b40f..e258544 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@leanadmin/alpine-typescript", - "version": "0.1.15", + "version": "0.1.16", "description": "TypeScript support for Alpine.js", "main": "dist/index.js", "repository": { diff --git a/src/index.ts b/src/index.ts index 29955bf..be2d4ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,3 @@ -declare const window: any; - type ComponentConstructor = (...args: any[]) => object; export abstract class AlpineComponent { @@ -113,7 +111,7 @@ export function convertClassToAlpineConstructor(component: any): ComponentConstr } export function addTitles(): void { - window.Alpine.onBeforeComponentInitialized((component: AlpineComponent) => { + window.Alpine.onBeforeComponentInitialized((component: ComponentController) => { if (! component.$el.hasAttribute('x-title')) { if (component.$data.constructor.prototype instanceof AlpineComponent) { component.$el.setAttribute('x-title', component.$data.constructor.name); @@ -137,3 +135,11 @@ export function bootstrap(): void { if (window.AlpineComponents === undefined) { bootstrap(); } + +declare global { + interface Window { + Alpine: Alpine; + deferLoadingAlpine: any; + AlpineComponents: any; + } +}