From 54e183c8f10de21d175aec2693ccfe14438db833 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 26 Aug 2017 11:36:22 -0700 Subject: [PATCH] Fixed up errors. --- types/moonjs/index.d.ts | 24 ++++++++++++------------ types/moonjs/moonjs-tests.ts | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/types/moonjs/index.d.ts b/types/moonjs/index.d.ts index 6cdf6d9867..2a6a9c2677 100644 --- a/types/moonjs/index.d.ts +++ b/types/moonjs/index.d.ts @@ -5,7 +5,7 @@ // TypeScript Version: 2.3 declare namespace Moon { - export interface Moon { + interface Instance { get(name: K): Data[K]; set(name: K, value: Data[K]): void; @@ -21,11 +21,11 @@ declare namespace Moon { $data: Data; } - export interface MoonConstructor { - new (options?: ThisAwareComponentOptions): Moon; + interface MoonConstructor { + new (options?: ThisAwareComponentOptions): Instance; } - export interface MoonStatic extends MoonConstructor { + interface MoonStatic extends MoonConstructor { component(name: string, options: ThisAwareComponentOptions): MoonConstructor; config: MoonConfig; use(plugin: object): void; @@ -34,11 +34,11 @@ declare namespace Moon { directive(name: string, action: (el: any, val: any) => void): void; } - export type ThisAwareComponentOptions = + type ThisAwareComponentOptions = & ComponentOptions - & ThisType>; + & ThisType>; - export interface ComponentOptions { + interface ComponentOptions { el?: string; template?: string; name?: string; @@ -51,12 +51,12 @@ declare namespace Moon { render?(h: CreateElement, ctx: any): VDomElement; } - export interface CreateElement { + interface CreateElement { (tag: "#text", attrs: Record, metadata?: any, children?: string): VDomElement; - (tag: string | Moon, attrs: Record, metadata?: any, children?: string | VDomElement[]): VDomElement; + (tag: string | Instance, attrs: Record, metadata?: any, children?: string | VDomElement[]): VDomElement; } - export interface VDomElement { + interface VDomElement { type: string; val: string; props: Record; @@ -64,14 +64,14 @@ declare namespace Moon { children: VDomElement[]; } - export interface LifecycleHooks { + interface LifecycleHooks { init?(): void; mounted?(): void; updated?(): void; destroyed?(): void; } - export interface MoonConfig { + interface MoonConfig { silent: boolean; prefix: string; keycodes(codemap: Record): void; diff --git a/types/moonjs/moonjs-tests.ts b/types/moonjs/moonjs-tests.ts index 9772394dd6..4dfb66d714 100644 --- a/types/moonjs/moonjs-tests.ts +++ b/types/moonjs/moonjs-tests.ts @@ -1,6 +1,6 @@ import Moon = require("moonjs"); -let app = new Moon({ +const app = new Moon({ data: { count: 0 }, @@ -11,7 +11,7 @@ let app = new Moon({ } }); -let count: number = app.get("count"); +const count: number = app.get("count"); app.get("increment")(); app.callMethod("increment"); @@ -40,9 +40,9 @@ new Moon({ } }); -var renderApp = new Moon({ +const renderApp = new Moon({ el: "#render", - render: (h) => { + render(h) { return h("div", { attrs: { id: "render" } }, { shouldRender: true, eventListeners: {} }, [h("#text", { shouldRender: true, eventListeners: {} }, this.get("msg"))]); }, data: { @@ -59,12 +59,12 @@ Moon.component("functional-component", { }); // Component instances should be subtypes of Moon. -var componentConstructor = Moon.component('my-component', { +const componentConstructor = Moon.component('my-component', { props: ['componentprop', 'otherprop'], template: "
{{componentprop}}
" }); -var moon: Moon = new componentConstructor(); +const moon: Moon.Instance = new componentConstructor(); componentConstructor instanceof Moon; Moon.config.silent = true;