Project

General

Profile

1
/*
2
 * Custom Type Definitions
3
 * When including 3rd party modules you also need to include the type definition for the module
4
 * if they don't provide one within the module. You can try to install it with typings
5
typings install node --save
6
 * If you can't find the type definition in the registry we can make an ambient definition in
7
 * this file for now. For example
8
declare module "my-module" {
9
  export function doesSomething(value: string): string;
10
}
11
 *
12
 * If you're prototying and you will fix the types later you can also declare it as type any
13
 *
14
declare var assert: any;
15
 *
16
 * If you're importing a module that uses Node.js modules which are CommonJS you need to import as
17
 *
18
import * as _ from 'lodash'
19
 * You can include your type definitions in this file until you create one for the typings registry
20
 * see https://github.com/typings/registry
21
 *
22
 */
23

    
24

    
25
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
26
declare var ENV: string;
27
declare var HMR: boolean;
28
interface GlobalEnvironment {
29
  ENV;
30
  HMR;
31
}
32

    
33
interface WebpackModule {
34
  hot: {
35
    data?: any,
36
    idle: any,
37
    accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
38
    decline(dependencies?: string | string[]): void;
39
    dispose(callback?: (data?: any) => void): void;
40
    addDisposeHandler(callback?: (data?: any) => void): void;
41
    removeDisposeHandler(callback?: (data?: any) => void): void;
42
    check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
43
    apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
44
    status(callback?: (status?: string) => void): void | string;
45
    removeStatusHandler(callback?: (status?: string) => void): void;
46
  };
47
}
48

    
49
interface WebpackRequire {
50
  context(file: string, flag?: boolean, exp?: RegExp): any;
51
}
52

    
53

    
54
interface ErrorStackTraceLimit {
55
  stackTraceLimit: number;
56
}
57

    
58

    
59
// Extend typings
60
interface NodeRequire extends WebpackRequire {}
61
interface ErrorConstructor extends ErrorStackTraceLimit {}
62
interface NodeModule extends WebpackModule {}
63
interface Global extends GlobalEnvironment  {}
64

    
65

    
66
interface Thenable<T> {
67
  then<U>(
68
    onFulfilled?: (value: T) => U | Thenable<U>,
69
    onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
70
  then<U>(
71
    onFulfilled?: (value: T) => U | Thenable<U>,
72
    onRejected?: (error: any) => void): Thenable<U>;
73
  catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
74
}
(7-7/7)