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
6 typings install node --save
8 * If you can't find the type definition in the registry we can make an ambient definition in
9 * this file for now. For example
11 declare module "my-module" {
12 export function doesSomething(value: string): string;
16 * If you're prototying and you will fix the types later you can also declare it as type any
19 declare var assert: any;
22 * If you're importing a module that uses Node.js modules which are CommonJS you need to import as
25 import * as _ from 'lodash'
27 * You can include your type definitions in this file until you create one for the typings registry
28 * see https://github.com/typings/registry
33 // Extra variables that live on Global that will be replaced by webpack DefinePlugin
34 declare var ENV: string;
35 declare var HMR: boolean;
36 interface GlobalEnvironment {
41 interface WebpackModule {
45 accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
46 decline(dependencies?: string | string[]): void;
47 dispose(callback?: (data?: any) => void): void;
48 addDisposeHandler(callback?: (data?: any) => void): void;
49 removeDisposeHandler(callback?: (data?: any) => void): void;
50 check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
51 apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
52 status(callback?: (status?: string) => void): void | string;
53 removeStatusHandler(callback?: (status?: string) => void): void;
57 interface WebpackRequire {
58 context(file: string, flag?: boolean, exp?: RegExp): any;
62 interface ErrorStackTraceLimit {
63 stackTraceLimit: number;
69 interface NodeRequire extends WebpackRequire {}
70 interface ErrorConstructor extends ErrorStackTraceLimit {}
71 interface NodeModule extends WebpackModule {}
72 interface Global extends GlobalEnvironment {}
75 declare namespace Reflect {
76 function decorate(decorators: ClassDecorator[], target: Function): Function;
78 decorators: (PropertyDecorator | MethodDecorator)[],
80 targetKey: string | symbol,
81 descriptor?: PropertyDescriptor): PropertyDescriptor;
83 function metadata(metadataKey: any, metadataValue: any): {
84 (target: Function): void;
85 (target: Object, propertyKey: string | symbol): void;
87 function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void;
88 function defineMetadata(
92 targetKey: string | symbol): void;
93 function hasMetadata(metadataKey: any, target: Object): boolean;
94 function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
95 function hasOwnMetadata(metadataKey: any, target: Object): boolean;
96 function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
97 function getMetadata(metadataKey: any, target: Object): any;
98 function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
99 function getOwnMetadata(metadataKey: any, target: Object): any;
100 function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
101 function getMetadataKeys(target: Object): any[];
102 function getMetadataKeys(target: Object, targetKey: string | symbol): any[];
103 function getOwnMetadataKeys(target: Object): any[];
104 function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[];
105 function deleteMetadata(metadataKey: any, target: Object): boolean;
106 function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
110 // We need this here since there is a problem with Zone.js typings
111 interface Thenable<T> {
113 onFulfilled?: (value: T) => U | Thenable<U>,
114 onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
116 onFulfilled?: (value: T) => U | Thenable<U>,
117 onRejected?: (error: any) => void): Thenable<U>;
118 catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;