// Type definitions for moonjs 0.11 // Project: https://github.com/KingPixil/moon // Definitions by: Daniel Rosenwasser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 declare namespace Moon { interface Instance { get(name: K): Data[K]; set(name: K, value: Data[K]): void; callMethod(methodName: K, params?: any[]): any; mount(selector: string): void; destroy(): void; build(): void; on(eventName: string, listener: (event: Event) => void): void; off(eventName?: string, listener?: (event: Event) => void): void; emit(eventName: string, data?: any): void; $data: Data; } interface MoonConstructor { new (options?: ConstructorOptions): Instance>; } interface MoonStatic extends MoonConstructor { component(name: string, options: ComponentOptions): MoonConstructor; config: MoonConfig; use(plugin: object): void; compile(template: string): void; nextTick(callback: () => void): void; directive(name: string, action: (el: any, val: any) => void): void; } type ConstructorOptions = & ComponentOptionsProperties Data) | Data, Methods> & ThisType>>; type ComponentOptions = & ComponentOptionsProperties Data, Methods> & ThisType>>; interface ComponentOptionsProperties { el?: string | HTMLElement; template?: string; name?: string; functional?: true; props?: Props[]; data?: Data; methods?: Methods; hooks?: LifecycleHooks; render?(h: CreateElement, ctx: any): VDomElement; } interface CreateElement { (tag: "#text", attrs: Record, metadata?: any, children?: string): VDomElement; (tag: string | Instance, attrs: Record, metadata?: any, children?: string | VDomElement[]): VDomElement; } interface VDomElement { type: string; val: string; props: Record; meta: object; children: VDomElement[]; } interface LifecycleHooks { init?(): void; mounted?(): void; updated?(): void; destroyed?(): void; } interface MoonConfig { silent: boolean; prefix: string; keycodes(codemap: Record): void; delimiters: string[]; version: string; } } // Declared as a module. declare var Moon: Moon.MoonStatic; export = Moon; // Also available as a global. export as namespace Moon;