]>
Commit | Line | Data |
---|---|---|
df98563e C |
1 | /* tslint: disable */ |
2 | ||
4a6995be C |
3 | /* |
4 | * Custom Type Definitions | |
5 | * When including 3rd party modules you also need to include the type definition for the module | |
ab32b0fc | 6 | * if they don't provide one within the module. You can try to install it with @types |
4a6995be | 7 | |
ab32b0fc C |
8 | npm install @types/node |
9 | npm install @types/lodash | |
4a6995be | 10 | |
ab32b0fc | 11 | * If you can't find the type definition in the registry we can make an ambient/global definition in |
4a6995be C |
12 | * this file for now. For example |
13 | ||
ab32b0fc C |
14 | declare module 'my-module' { |
15 | export function doesSomething(value: string): string; | |
16 | } | |
17 | ||
18 | * If you are using a CommonJS module that is using module.exports then you will have to write your | |
19 | * types using export = yourObjectOrFunction with a namespace above it | |
20 | * notice how we have to create a namespace that is equal to the function we're | |
21 | * assigning the export to | |
22 | ||
23 | declare module 'jwt-decode' { | |
24 | function jwtDecode(token: string): any; | |
25 | namespace jwtDecode {} | |
26 | export = jwtDecode; | |
4a6995be C |
27 | } |
28 | ||
29 | * | |
30 | * If you're prototying and you will fix the types later you can also declare it as type any | |
31 | * | |
32 | ||
33 | declare var assert: any; | |
ab32b0fc C |
34 | declare var _: any; |
35 | declare var $: any; | |
4a6995be C |
36 | |
37 | * | |
38 | * If you're importing a module that uses Node.js modules which are CommonJS you need to import as | |
ab32b0fc | 39 | * in the files such as main.browser.ts or any file within app/ |
4a6995be C |
40 | * |
41 | ||
42 | import * as _ from 'lodash' | |
43 | ||
ab32b0fc | 44 | * You can include your type definitions in this file until you create one for the @types |
4a6995be C |
45 | * |
46 | */ | |
47 | ||
ab32b0fc C |
48 | // support NodeJS modules without type definitions |
49 | declare module '*'; | |
4a6995be | 50 | |
c16ce1de C |
51 | /* |
52 | // for legacy tslint etc to understand rename 'modern-lru' with your package | |
53 | // then comment out `declare module '*';`. For each new module copy/paste | |
54 | // this method of creating an `any` module type definition | |
55 | declare module 'modern-lru' { | |
56 | let x: any; | |
57 | export = x; | |
58 | } | |
59 | */ | |
60 | ||
4a6995be C |
61 | // Extra variables that live on Global that will be replaced by webpack DefinePlugin |
62 | declare var ENV: string; | |
1840c2f7 | 63 | declare var API_URL: string; |
4a6995be | 64 | declare var HMR: boolean; |
ab32b0fc C |
65 | declare var System: SystemJS; |
66 | ||
67 | interface SystemJS { | |
68 | import: (path?: string) => Promise<any>; | |
69 | } | |
70 | ||
4a6995be | 71 | interface GlobalEnvironment { |
c16ce1de | 72 | ENV: string; |
1840c2f7 | 73 | API_URL: string; |
c16ce1de | 74 | HMR: boolean; |
ab32b0fc C |
75 | SystemJS: SystemJS; |
76 | System: SystemJS; | |
4a6995be C |
77 | } |
78 | ||
ab32b0fc C |
79 | interface Es6PromiseLoader { |
80 | (id: string): (exportName?: string) => Promise<any>; | |
81 | } | |
82 | ||
83 | type FactoryEs6PromiseLoader = () => Es6PromiseLoader; | |
84 | type FactoryPromise = () => Promise<any>; | |
85 | ||
86 | type AsyncRoutes = { | |
87 | [component: string]: Es6PromiseLoader | | |
88 | Function | | |
89 | FactoryEs6PromiseLoader | | |
8635a2c7 | 90 | FactoryPromise ; |
ab32b0fc C |
91 | }; |
92 | ||
ab32b0fc C |
93 | type IdleCallbacks = Es6PromiseLoader | |
94 | Function | | |
95 | FactoryEs6PromiseLoader | | |
96 | FactoryPromise ; | |
97 | ||
4a6995be C |
98 | interface WebpackModule { |
99 | hot: { | |
100 | data?: any, | |
101 | idle: any, | |
102 | accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void; | |
ab32b0fc | 103 | decline(deps?: any | string | string[]): void; |
4a6995be C |
104 | dispose(callback?: (data?: any) => void): void; |
105 | addDisposeHandler(callback?: (data?: any) => void): void; | |
106 | removeDisposeHandler(callback?: (data?: any) => void): void; | |
107 | check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void; | |
108 | apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void; | |
109 | status(callback?: (status?: string) => void): void | string; | |
110 | removeStatusHandler(callback?: (status?: string) => void): void; | |
111 | }; | |
112 | } | |
113 | ||
114 | interface WebpackRequire { | |
ab32b0fc C |
115 | (id: string): any; |
116 | (paths: string[], callback: (...modules: any[]) => void): void; | |
117 | ensure(ids: string[], callback: (req: WebpackRequire) => void, chunkName?: string): void; | |
118 | context(directory: string, useSubDirectories?: boolean, regExp?: RegExp): WebpackContext; | |
4a6995be C |
119 | } |
120 | ||
ab32b0fc C |
121 | interface WebpackContext extends WebpackRequire { |
122 | keys(): string[]; | |
123 | } | |
4a6995be C |
124 | |
125 | interface ErrorStackTraceLimit { | |
126 | stackTraceLimit: number; | |
127 | } | |
128 | ||
4a6995be C |
129 | // Extend typings |
130 | interface NodeRequire extends WebpackRequire {} | |
131 | interface ErrorConstructor extends ErrorStackTraceLimit {} | |
ab32b0fc | 132 | interface NodeRequireFunction extends Es6PromiseLoader {} |
4a6995be C |
133 | interface NodeModule extends WebpackModule {} |
134 | interface Global extends GlobalEnvironment {} |