mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Fixed up errors.
This commit is contained in:
Vendored
+12
-12
@@ -5,7 +5,7 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace Moon {
|
||||
export interface Moon<Data> {
|
||||
interface Instance<Data> {
|
||||
get<K extends keyof Data>(name: K): Data[K];
|
||||
set<K extends keyof Data>(name: K, value: Data[K]): void;
|
||||
|
||||
@@ -21,11 +21,11 @@ declare namespace Moon {
|
||||
$data: Data;
|
||||
}
|
||||
|
||||
export interface MoonConstructor {
|
||||
new <Props extends string, Data, Methods>(options?: ThisAwareComponentOptions<Props, Data, Methods>): Moon<Data & Methods>;
|
||||
interface MoonConstructor {
|
||||
new <Props extends string, Data, Methods>(options?: ThisAwareComponentOptions<Props, Data, Methods>): Instance<Data & Methods>;
|
||||
}
|
||||
|
||||
export interface MoonStatic extends MoonConstructor {
|
||||
interface MoonStatic extends MoonConstructor {
|
||||
component<Props extends string, Data, Methods>(name: string, options: ThisAwareComponentOptions<Props, Data, Methods>): 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<Props extends string, Data, Methods> =
|
||||
type ThisAwareComponentOptions<Props extends string, Data, Methods> =
|
||||
& ComponentOptions<Props, Data, Methods>
|
||||
& ThisType<Moon<Data & Methods>>;
|
||||
& ThisType<Instance<Data & Methods>>;
|
||||
|
||||
export interface ComponentOptions<Props extends string, Data, Methods> {
|
||||
interface ComponentOptions<Props extends string, Data, Methods> {
|
||||
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<string, any>, metadata?: any, children?: string): VDomElement;
|
||||
(tag: string | Moon<object>, attrs: Record<string, any>, metadata?: any, children?: string | VDomElement[]): VDomElement;
|
||||
(tag: string | Instance<object>, attrs: Record<string, any>, metadata?: any, children?: string | VDomElement[]): VDomElement;
|
||||
}
|
||||
|
||||
export interface VDomElement {
|
||||
interface VDomElement {
|
||||
type: string;
|
||||
val: string;
|
||||
props: Record<string, any>;
|
||||
@@ -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<string, number>): void;
|
||||
|
||||
@@ -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: "<div>{{componentprop}}</div>"
|
||||
});
|
||||
|
||||
var moon: Moon<object> = new componentConstructor();
|
||||
const moon: Moon.Instance<object> = new componentConstructor();
|
||||
componentConstructor instanceof Moon;
|
||||
|
||||
Moon.config.silent = true;
|
||||
|
||||
Reference in New Issue
Block a user