#506 allow AMD modules to load from typescript

This commit is contained in:
Leo Horie 2015-03-24 20:45:43 -04:00
parent 117739ce1c
commit 577d0f7039

81
mithril.d.ts vendored
View file

@ -1,6 +1,6 @@
//Mithril type definitions for Typescript
interface MithrilStatic {
declare module _mithril {
interface MithrilStatic {
(selector: string, attributes: MithrilAttributes, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
(selector: string, ...children: Array<string|MithrilVirtualElement>): MithrilVirtualElement;
@ -55,92 +55,92 @@ interface MithrilStatic {
factory: Object;
}
}
}
interface MithrilVirtualElement {
interface MithrilVirtualElement {
key?: number;
tag?: string;
attrs?: MithrilAttributes;
children?: any[];
}
}
// Configuration function for an element
interface MithrilElementConfig {
// Configuration function for an element
interface MithrilElementConfig {
(element: Element, isInitialized: boolean, context?: any): void;
}
}
// Attributes on a virtual element
interface MithrilAttributes {
// Attributes on a virtual element
interface MithrilAttributes {
title?: string;
className?: string;
class?: string;
config?: MithrilElementConfig;
}
}
// Defines the subset of Event that Mithril needs
interface MithrilEvent {
// Defines the subset of Event that Mithril needs
interface MithrilEvent {
currentTarget: Element;
}
}
interface MithrilController {
interface MithrilController {
onunload?(evt: Event): any;
}
}
interface MithrilControllerFunction extends MithrilController {
interface MithrilControllerFunction extends MithrilController {
(): any;
}
}
interface MithrilView<T extends MithrilController> {
interface MithrilView<T extends MithrilController> {
(ctrl: T): string|MithrilVirtualElement;
}
}
interface MithrilModule<T extends MithrilController> {
interface MithrilModule<T extends MithrilController> {
controller: MithrilControllerFunction|{ new(): T };
view: MithrilView<T>;
}
}
interface MithrilProperty<T> {
interface MithrilProperty<T> {
(): T;
(value: T): T;
toJSON(): T;
}
}
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
(): T;
(value: T): T;
toJSON(): T;
}
}
interface MithrilRoutes<T extends MithrilController> {
interface MithrilRoutes<T extends MithrilController> {
[key: string]: MithrilModule<T>;
}
}
interface MithrilDeferred<T> {
interface MithrilDeferred<T> {
resolve(value?: T): void;
reject(value?: any): void;
promise: MithrilPromise<T>;
}
}
interface MithrilSuccessCallback<T, U> {
interface MithrilSuccessCallback<T, U> {
(value: T): U;
(value: T): MithrilPromise<U>;
}
}
interface MithrilErrorCallback<U> {
interface MithrilErrorCallback<U> {
(value: Error): U;
(value: string): U;
}
}
interface MithrilPromise<T> {
interface MithrilPromise<T> {
(): T;
(value: T): T;
then<U>(success: (value: T) => 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) => MithrilPromise<U>, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
}
interface MithrilXHROptions {
}
interface MithrilXHROptions {
method?: string;
url: string;
user?: string;
@ -155,11 +155,12 @@ interface MithrilXHROptions {
type?(data: Object): void;
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
dataType?: string;
}
}
declare var Mithril: MithrilStatic;
declare var m: MithrilStatic;
declare var Mithril: _mithril.MithrilStatic;
declare var m: _mithril.MithrilStatic;
declare module 'mithril' {
declare module "mithril" {
export = m;
}