#506 allow AMD modules to load from typescript
This commit is contained in:
parent
117739ce1c
commit
577d0f7039
1 changed files with 144 additions and 143 deletions
81
mithril.d.ts
vendored
81
mithril.d.ts
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
//Mithril type definitions for Typescript
|
//Mithril type definitions for Typescript
|
||||||
|
declare module _mithril {
|
||||||
interface MithrilStatic {
|
interface MithrilStatic {
|
||||||
|
|
||||||
(selector: string, attributes: MithrilAttributes, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
|
(selector: string, attributes: MithrilAttributes, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
|
||||||
(selector: string, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
|
(selector: string, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
|
||||||
|
|
@ -55,92 +55,92 @@ interface MithrilStatic {
|
||||||
factory: Object;
|
factory: Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilVirtualElement {
|
interface MithrilVirtualElement {
|
||||||
key?: number;
|
key?: number;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
attrs?: MithrilAttributes;
|
attrs?: MithrilAttributes;
|
||||||
children?: any[];
|
children?: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration function for an element
|
// Configuration function for an element
|
||||||
interface MithrilElementConfig {
|
interface MithrilElementConfig {
|
||||||
(element: Element, isInitialized: boolean, context?: any): void;
|
(element: Element, isInitialized: boolean, context?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attributes on a virtual element
|
// Attributes on a virtual element
|
||||||
interface MithrilAttributes {
|
interface MithrilAttributes {
|
||||||
title?: string;
|
title?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
class?: string;
|
class?: string;
|
||||||
config?: MithrilElementConfig;
|
config?: MithrilElementConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the subset of Event that Mithril needs
|
// Defines the subset of Event that Mithril needs
|
||||||
interface MithrilEvent {
|
interface MithrilEvent {
|
||||||
currentTarget: Element;
|
currentTarget: Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilController {
|
interface MithrilController {
|
||||||
onunload?(evt: Event): any;
|
onunload?(evt: Event): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilControllerFunction extends MithrilController {
|
interface MithrilControllerFunction extends MithrilController {
|
||||||
(): any;
|
(): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilView<T extends MithrilController> {
|
interface MithrilView<T extends MithrilController> {
|
||||||
(ctrl: T): string|MithrilVirtualElement;
|
(ctrl: T): string|MithrilVirtualElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilModule<T extends MithrilController> {
|
interface MithrilModule<T extends MithrilController> {
|
||||||
controller: MithrilControllerFunction|{ new(): T };
|
controller: MithrilControllerFunction|{ new(): T };
|
||||||
view: MithrilView<T>;
|
view: MithrilView<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilProperty<T> {
|
interface MithrilProperty<T> {
|
||||||
(): T;
|
(): T;
|
||||||
(value: T): T;
|
(value: T): T;
|
||||||
toJSON(): T;
|
toJSON(): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
|
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
|
||||||
(): T;
|
(): T;
|
||||||
(value: T): T;
|
(value: T): T;
|
||||||
toJSON(): T;
|
toJSON(): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilRoutes<T extends MithrilController> {
|
interface MithrilRoutes<T extends MithrilController> {
|
||||||
[key: string]: MithrilModule<T>;
|
[key: string]: MithrilModule<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface MithrilDeferred<T> {
|
interface MithrilDeferred<T> {
|
||||||
resolve(value?: T): void;
|
resolve(value?: T): void;
|
||||||
reject(value?: any): void;
|
reject(value?: any): void;
|
||||||
promise: MithrilPromise<T>;
|
promise: MithrilPromise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilSuccessCallback<T, U> {
|
interface MithrilSuccessCallback<T, U> {
|
||||||
(value: T): U;
|
(value: T): U;
|
||||||
(value: T): MithrilPromise<U>;
|
(value: T): MithrilPromise<U>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilErrorCallback<U> {
|
interface MithrilErrorCallback<U> {
|
||||||
(value: Error): U;
|
(value: Error): U;
|
||||||
(value: string): U;
|
(value: string): U;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MithrilPromise<T> {
|
interface MithrilPromise<T> {
|
||||||
(): T;
|
(): T;
|
||||||
(value: T): T;
|
(value: T): T;
|
||||||
then<U>(success: (value: T) => U): MithrilPromise<U>;
|
then<U>(success: (value: T) => U): MithrilPromise<U>;
|
||||||
then<U>(success: (value: T) => MithrilPromise<U>): MithrilPromise<U>;
|
then<U>(success: (value: T) => MithrilPromise<U>): MithrilPromise<U>;
|
||||||
then<U,V>(success: (value: T) => U, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
|
then<U,V>(success: (value: T) => U, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
|
||||||
then<U,V>(success: (value: T) => MithrilPromise<U>, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
|
then<U,V>(success: (value: T) => MithrilPromise<U>, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
|
||||||
}
|
}
|
||||||
interface MithrilXHROptions {
|
interface MithrilXHROptions {
|
||||||
method?: string;
|
method?: string;
|
||||||
url: string;
|
url: string;
|
||||||
user?: string;
|
user?: string;
|
||||||
|
|
@ -155,11 +155,12 @@ interface MithrilXHROptions {
|
||||||
type?(data: Object): void;
|
type?(data: Object): void;
|
||||||
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
|
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var Mithril: MithrilStatic;
|
declare var Mithril: _mithril.MithrilStatic;
|
||||||
declare var m: MithrilStatic;
|
declare var m: _mithril.MithrilStatic;
|
||||||
|
|
||||||
declare module 'mithril' {
|
declare module "mithril" {
|
||||||
export = m;
|
export = m;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue