2016-06-03 15:08:03 -05:00
|
|
|
/*
|
|
|
|
* Custom Type Definitions
|
|
|
|
* When including 3rd party modules you also need to include the type definition for the module
|
2016-09-06 15:40:57 -05:00
|
|
|
* if they don't provide one within the module. You can try to install it with @types
|
2016-06-03 15:08:03 -05:00
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
npm install @types/node
|
|
|
|
npm install @types/lodash
|
2016-06-03 15:08:03 -05:00
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
* If you can't find the type definition in the registry we can make an ambient/global definition in
|
2016-06-03 15:08:03 -05:00
|
|
|
* this file for now. For example
|
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
declare module 'my-module' {
|
|
|
|
export function doesSomething(value: string): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
* If you are using a CommonJS module that is using module.exports then you will have to write your
|
|
|
|
* types using export = yourObjectOrFunction with a namespace above it
|
|
|
|
* notice how we have to create a namespace that is equal to the function we're
|
|
|
|
* assigning the export to
|
|
|
|
|
|
|
|
declare module 'jwt-decode' {
|
|
|
|
function jwtDecode(token: string): any;
|
|
|
|
namespace jwtDecode {}
|
|
|
|
export = jwtDecode;
|
2016-06-03 15:08:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
*
|
|
|
|
* If you're prototying and you will fix the types later you can also declare it as type any
|
|
|
|
*
|
|
|
|
|
|
|
|
declare var assert: any;
|
2016-09-06 15:40:57 -05:00
|
|
|
declare var _: any;
|
|
|
|
declare var $: any;
|
2016-06-03 15:08:03 -05:00
|
|
|
|
|
|
|
*
|
|
|
|
* If you're importing a module that uses Node.js modules which are CommonJS you need to import as
|
2016-09-06 15:40:57 -05:00
|
|
|
* in the files such as main.browser.ts or any file within app/
|
2016-06-03 15:08:03 -05:00
|
|
|
*
|
|
|
|
|
|
|
|
import * as _ from 'lodash'
|
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
* You can include your type definitions in this file until you create one for the @types
|
2016-06-03 15:08:03 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
// support NodeJS modules without type definitions
|
|
|
|
declare module '*';
|
2016-06-03 15:08:03 -05:00
|
|
|
|
2017-01-13 05:16:00 -06:00
|
|
|
/*
|
|
|
|
// for legacy tslint etc to understand rename 'modern-lru' with your package
|
|
|
|
// then comment out `declare module '*';`. For each new module copy/paste
|
|
|
|
// this method of creating an `any` module type definition
|
|
|
|
declare module 'modern-lru' {
|
|
|
|
let x: any;
|
|
|
|
export = x;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2016-06-03 15:08:03 -05:00
|
|
|
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
|
|
|
declare var ENV: string;
|
|
|
|
declare var HMR: boolean;
|
2016-09-06 15:40:57 -05:00
|
|
|
declare var System: SystemJS;
|
|
|
|
|
|
|
|
interface SystemJS {
|
|
|
|
import: (path?: string) => Promise<any>;
|
|
|
|
}
|
|
|
|
|
2016-06-03 15:08:03 -05:00
|
|
|
interface GlobalEnvironment {
|
2017-01-13 05:16:00 -06:00
|
|
|
ENV: string;
|
|
|
|
HMR: boolean;
|
2016-09-06 15:40:57 -05:00
|
|
|
SystemJS: SystemJS;
|
|
|
|
System: SystemJS;
|
2016-06-03 15:08:03 -05:00
|
|
|
}
|
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
interface Es6PromiseLoader {
|
|
|
|
(id: string): (exportName?: string) => Promise<any>;
|
|
|
|
}
|
|
|
|
|
|
|
|
type FactoryEs6PromiseLoader = () => Es6PromiseLoader;
|
|
|
|
type FactoryPromise = () => Promise<any>;
|
|
|
|
|
|
|
|
type AsyncRoutes = {
|
|
|
|
[component: string]: Es6PromiseLoader |
|
|
|
|
Function |
|
|
|
|
FactoryEs6PromiseLoader |
|
|
|
|
FactoryPromise
|
|
|
|
};
|
|
|
|
|
|
|
|
type IdleCallbacks = Es6PromiseLoader |
|
|
|
|
Function |
|
|
|
|
FactoryEs6PromiseLoader |
|
|
|
|
FactoryPromise ;
|
|
|
|
|
2016-06-03 15:08:03 -05:00
|
|
|
interface WebpackModule {
|
|
|
|
hot: {
|
|
|
|
data?: any,
|
|
|
|
idle: any,
|
|
|
|
accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
|
2016-09-06 15:40:57 -05:00
|
|
|
decline(deps?: any | string | string[]): void;
|
2016-06-03 15:08:03 -05:00
|
|
|
dispose(callback?: (data?: any) => void): void;
|
|
|
|
addDisposeHandler(callback?: (data?: any) => void): void;
|
|
|
|
removeDisposeHandler(callback?: (data?: any) => void): void;
|
|
|
|
check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
|
|
|
|
apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
|
|
|
|
status(callback?: (status?: string) => void): void | string;
|
|
|
|
removeStatusHandler(callback?: (status?: string) => void): void;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
interface WebpackRequire {
|
2016-09-06 15:40:57 -05:00
|
|
|
(id: string): any;
|
|
|
|
(paths: string[], callback: (...modules: any[]) => void): void;
|
|
|
|
ensure(ids: string[], callback: (req: WebpackRequire) => void, chunkName?: string): void;
|
|
|
|
context(directory: string, useSubDirectories?: boolean, regExp?: RegExp): WebpackContext;
|
2016-06-03 15:08:03 -05:00
|
|
|
}
|
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
interface WebpackContext extends WebpackRequire {
|
|
|
|
keys(): string[];
|
|
|
|
}
|
2016-06-03 15:08:03 -05:00
|
|
|
|
|
|
|
interface ErrorStackTraceLimit {
|
|
|
|
stackTraceLimit: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extend typings
|
|
|
|
interface NodeRequire extends WebpackRequire {}
|
|
|
|
interface ErrorConstructor extends ErrorStackTraceLimit {}
|
2016-09-06 15:40:57 -05:00
|
|
|
interface NodeRequireFunction extends Es6PromiseLoader {}
|
2016-06-03 15:08:03 -05:00
|
|
|
interface NodeModule extends WebpackModule {}
|
|
|
|
interface Global extends GlobalEnvironment {}
|