1
0
Fork 0
mirror of https://github.com/archtechx/alpine-typescript.git synced 2025-12-12 06:44:03 +00:00
This commit is contained in:
Samuel Štancl 2021-05-23 18:54:36 +02:00
parent b44e59682a
commit 459caba878
3 changed files with 17 additions and 4 deletions

View file

@ -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;
}
}