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
// declare module '*'; // default type definitions for any for modules that are not found.
25
// caveat: if this is enabled and you do not have the proper module there may not be an error.
26
// suggestion: follow the pattern below with modern-lru which provides an alternative way to create an 'any' module.
27

    
28
// for legacy tslint etc to understand
29
declare module 'modern-lru' {
30
  let x: any;
31
  export = x;
32
}
33

    
34
declare var System: SystemJS;
35

    
36
interface SystemJS {
37
  import: (path?: string) => Promise<any>;
38
}
39
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
40
declare var ENV: string;
41
declare var HMR: boolean;
42
declare var Zone: {current: any};
43
interface GlobalEnvironment {
44
  ENV;
45
  HMR;
46
  SystemJS: SystemJS;
47
  System: SystemJS;
48
}
49

    
50
interface WebpackModule {
51
  hot: {
52
    data?: any,
53
    idle: any,
54
    accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
55
    decline(dependencies?: string | string[]): void;
56
    dispose(callback?: (data?: any) => void): void;
57
    addDisposeHandler(callback?: (data?: any) => void): void;
58
    removeDisposeHandler(callback?: (data?: any) => void): void;
59
    check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
60
    apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
61
    status(callback?: (status?: string) => void): void | string;
62
    removeStatusHandler(callback?: (status?: string) => void): void;
63
  };
64
}
65

    
66
interface WebpackRequire {
67
  context(file: string, flag?: boolean, exp?: RegExp): any;
68
}
69

    
70
// Extend typings
71
interface NodeRequire extends WebpackRequire {}
72
interface NodeModule extends WebpackModule {}
73
interface Global extends GlobalEnvironment  {}
(12-12/12)