declare module 'marty' { import React = require('react'); module Marty { interface Map { [name: string]: T } interface FetchOptions { id: string; locally?: () => T; remotely?: () => Promise; dependsOn?: FetchResult | Array>; cacheError?: boolean; } interface WhenHandlers { done(result: T): any; failed(error: any): any; pending(): any; } interface When { (handlers: WhenHandlers, context?: any): void; all(fetchResult: FetchResult[], handlers: WhenHandlers>, context?: any): void; toPromise(): Promise; } interface FetchResult { status: string; failed: boolean; error?: any; result?: T; done: boolean; when: When; toPromise: () => Promise; } interface Fetch { (options: FetchOptions): FetchResult; (id: string, local: () => T, remote?: () => Promise): FetchResult; done(result: T, id: string, store: Store): FetchResult; pending(id: string, store: Store): FetchResult; failed(error: any, id: string, store: Store): FetchResult; notFound(id: string, store: Store): FetchResult; } type MartyInstance = Store | ActionCreators | Queries | StateSource; type MartyType = { new (...args: any[]): MartyInstance }; interface RegisterMap { [id: string]: RegisterMap | MartyType; } class Application { register(map: RegisterMap): void; register(id: string, instance: MartyType): void; } class ApplicationContainer extends React.Component<{ app: Application }, {}> {} class Store { state: S; handlers: any; dispatchToken: string; app: any; constructor(options: any); setState(nextState: S): void; replaceState(nextState: S): void; addChangeListener(callback: (state: S, store: Store) => any, context: any): void; hasChanged(): void; fetch: Fetch; hasAlreadyFetched(id: string): boolean; waitFor(stores: Array>): void; } class ActionCreators { id: string; app: Marty; dispatch(type: string, ...data: any[]): void; } class Queries extends DispatchCoordinator { id: string; app: Marty; dispatch(type: string, ...data: any[]): void; } type ContainerConfigFetch = Map | (() => Map); interface ContainerConfig { listenTo: string | Array; fetch?: ContainerConfigFetch; done?: (props: any) => React.ReactElement; pending?: () => React.ReactElement; failed?: (errors: any[]) => React.ReactElement; } function createContainer(component: React.ComponentClass, config?: ContainerConfig): React.ClassicComponentClass<{}>; class StateSource { id: string; type: string; mixins: Array; app: any; } class CookieStateSource extends StateSource { get(key: string): any; set(key: string, value: any): boolean; expire(key: string): boolean; } interface RequestOptions { url: string; method?: string; headers?: Map; body?: string | Object; contentType?: string; dataType?: string; } interface HttpFetch { text(): Promise; json(): Promise; headers: { get(key: string): string; } status: number; statusText: string; } interface HookOptions { id: string; priority?: number; before?: (req: any) => any; after?: (res: any) => any; } class HttpStateSource extends StateSource { baseUrl: string; request(options: RequestOptions): Promise; get(url: string): Promise; get(options: RequestOptions): Promise; post(url: string): Promise; post(options: RequestOptions): Promise; put(url: string): Promise; put(options: RequestOptions): Promise; delete(url: string): Promise; delete(options: RequestOptions): Promise; static addHook(options: HookOptions): void; static removeHook(options: HookOptions): void; } class JSONStorageStateSource extends StateSource { storage: any; namespace: string; get(key: string): any; set(key: string, value: any): void; } class LocalStorageStateSource extends JSONStorageStateSource {} class SessionStorageStateSource extends JSONStorageStateSource {} interface LocationInformation { url: string; path: string; hostname: string; query: Map; protocol: string; } class LocationStateSource extends StateSource { getLocation(): LocationInformation } function get(type: string, id: string): any; function getAll(type: string): any[]; function getDefault(type: string, id: string): any; function getAllDefaults(type: string): any[]; function resolve(type: string, id: string, options?: Object): any; interface Dispatcher { id: string; isDefault: boolean; dispatchAction(options: Object): any; onActionDispatched(callback: (action: any) => any, context?: any): void; } var dispatcher: Dispatcher; interface ConstantsOption { [key: string]: string[] | ConstantsOption; } function createConstants(constants: string[] | ConstantsOption): any; interface Warnings { without(warningsToDisable: string[], callback: () => any, context?: any): void; invokeConstant: boolean; reservedFunction: boolean; cannotFindContext: boolean; classDoesNotHaveAnId: boolean; stateIsNullOrUndefined: boolean; callingResolverOnServer: boolean; stateSourceAlreadyExists: boolean; superNotCalledWithOptions: boolean; promiseNotReturnedFromRemotely: boolean; contextNotPassedInToConstructor: boolean; } var warnings: Warnings; function createInstance(): typeof Marty; function dispose(): void; var version: string; var isServer: boolean; var isBrowser: boolean; } import M = Marty; export = M; }