diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /client/src/custom-typings.d.ts | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip |
Merge branch 'master' into webseed-merged
Diffstat (limited to 'client/src/custom-typings.d.ts')
-rw-r--r-- | client/src/custom-typings.d.ts | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/client/src/custom-typings.d.ts b/client/src/custom-typings.d.ts index 14c7d8ade..95787181f 100644 --- a/client/src/custom-typings.d.ts +++ b/client/src/custom-typings.d.ts | |||
@@ -1,15 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * Custom Type Definitions | 2 | * Custom Type Definitions |
3 | * When including 3rd party modules you also need to include the type definition for the module | 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 | 4 | * if they don't provide one within the module. You can try to install it with @types |
5 | 5 | ||
6 | typings install node --save | 6 | npm install @types/node |
7 | npm install @types/lodash | ||
7 | 8 | ||
8 | * If you can't find the type definition in the registry we can make an ambient definition in | 9 | * If you can't find the type definition in the registry we can make an ambient/global definition in |
9 | * this file for now. For example | 10 | * this file for now. For example |
10 | 11 | ||
11 | declare module "my-module" { | 12 | declare module 'my-module' { |
12 | export function doesSomething(value: string): string; | 13 | export function doesSomething(value: string): string; |
14 | } | ||
15 | |||
16 | * If you are using a CommonJS module that is using module.exports then you will have to write your | ||
17 | * types using export = yourObjectOrFunction with a namespace above it | ||
18 | * notice how we have to create a namespace that is equal to the function we're | ||
19 | * assigning the export to | ||
20 | |||
21 | declare module 'jwt-decode' { | ||
22 | function jwtDecode(token: string): any; | ||
23 | namespace jwtDecode {} | ||
24 | export = jwtDecode; | ||
13 | } | 25 | } |
14 | 26 | ||
15 | * | 27 | * |
@@ -17,33 +29,65 @@ declare module "my-module" { | |||
17 | * | 29 | * |
18 | 30 | ||
19 | declare var assert: any; | 31 | declare var assert: any; |
32 | declare var _: any; | ||
33 | declare var $: any; | ||
20 | 34 | ||
21 | * | 35 | * |
22 | * If you're importing a module that uses Node.js modules which are CommonJS you need to import as | 36 | * If you're importing a module that uses Node.js modules which are CommonJS you need to import as |
37 | * in the files such as main.browser.ts or any file within app/ | ||
23 | * | 38 | * |
24 | 39 | ||
25 | import * as _ from 'lodash' | 40 | import * as _ from 'lodash' |
26 | 41 | ||
27 | * You can include your type definitions in this file until you create one for the typings registry | 42 | * You can include your type definitions in this file until you create one for the @types |
28 | * see https://github.com/typings/registry | ||
29 | * | 43 | * |
30 | */ | 44 | */ |
31 | 45 | ||
46 | // support NodeJS modules without type definitions | ||
47 | declare module '*'; | ||
32 | 48 | ||
33 | // Extra variables that live on Global that will be replaced by webpack DefinePlugin | 49 | // Extra variables that live on Global that will be replaced by webpack DefinePlugin |
34 | declare var ENV: string; | 50 | declare var ENV: string; |
35 | declare var HMR: boolean; | 51 | declare var HMR: boolean; |
52 | declare var System: SystemJS; | ||
53 | |||
54 | interface SystemJS { | ||
55 | import: (path?: string) => Promise<any>; | ||
56 | } | ||
57 | |||
36 | interface GlobalEnvironment { | 58 | interface GlobalEnvironment { |
37 | ENV; | 59 | ENV; |
38 | HMR; | 60 | HMR; |
61 | SystemJS: SystemJS; | ||
62 | System: SystemJS; | ||
39 | } | 63 | } |
40 | 64 | ||
65 | interface Es6PromiseLoader { | ||
66 | (id: string): (exportName?: string) => Promise<any>; | ||
67 | } | ||
68 | |||
69 | type FactoryEs6PromiseLoader = () => Es6PromiseLoader; | ||
70 | type FactoryPromise = () => Promise<any>; | ||
71 | |||
72 | type AsyncRoutes = { | ||
73 | [component: string]: Es6PromiseLoader | | ||
74 | Function | | ||
75 | FactoryEs6PromiseLoader | | ||
76 | FactoryPromise | ||
77 | }; | ||
78 | |||
79 | |||
80 | type IdleCallbacks = Es6PromiseLoader | | ||
81 | Function | | ||
82 | FactoryEs6PromiseLoader | | ||
83 | FactoryPromise ; | ||
84 | |||
41 | interface WebpackModule { | 85 | interface WebpackModule { |
42 | hot: { | 86 | hot: { |
43 | data?: any, | 87 | data?: any, |
44 | idle: any, | 88 | idle: any, |
45 | accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void; | 89 | accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void; |
46 | decline(dependencies?: string | string[]): void; | 90 | decline(deps?: any | string | string[]): void; |
47 | dispose(callback?: (data?: any) => void): void; | 91 | dispose(callback?: (data?: any) => void): void; |
48 | addDisposeHandler(callback?: (data?: any) => void): void; | 92 | addDisposeHandler(callback?: (data?: any) => void): void; |
49 | removeDisposeHandler(callback?: (data?: any) => void): void; | 93 | removeDisposeHandler(callback?: (data?: any) => void): void; |
@@ -54,66 +98,26 @@ interface WebpackModule { | |||
54 | }; | 98 | }; |
55 | } | 99 | } |
56 | 100 | ||
101 | |||
57 | interface WebpackRequire { | 102 | interface WebpackRequire { |
58 | context(file: string, flag?: boolean, exp?: RegExp): any; | 103 | (id: string): any; |
104 | (paths: string[], callback: (...modules: any[]) => void): void; | ||
105 | ensure(ids: string[], callback: (req: WebpackRequire) => void, chunkName?: string): void; | ||
106 | context(directory: string, useSubDirectories?: boolean, regExp?: RegExp): WebpackContext; | ||
59 | } | 107 | } |
60 | 108 | ||
109 | interface WebpackContext extends WebpackRequire { | ||
110 | keys(): string[]; | ||
111 | } | ||
61 | 112 | ||
62 | interface ErrorStackTraceLimit { | 113 | interface ErrorStackTraceLimit { |
63 | stackTraceLimit: number; | 114 | stackTraceLimit: number; |
64 | } | 115 | } |
65 | 116 | ||
66 | 117 | ||
67 | |||
68 | // Extend typings | 118 | // Extend typings |
69 | interface NodeRequire extends WebpackRequire {} | 119 | interface NodeRequire extends WebpackRequire {} |
70 | interface ErrorConstructor extends ErrorStackTraceLimit {} | 120 | interface ErrorConstructor extends ErrorStackTraceLimit {} |
121 | interface NodeRequireFunction extends Es6PromiseLoader {} | ||
71 | interface NodeModule extends WebpackModule {} | 122 | interface NodeModule extends WebpackModule {} |
72 | interface Global extends GlobalEnvironment {} | 123 | interface Global extends GlobalEnvironment {} |
73 | |||
74 | |||
75 | declare namespace Reflect { | ||
76 | function decorate(decorators: ClassDecorator[], target: Function): Function; | ||
77 | function decorate( | ||
78 | decorators: (PropertyDecorator | MethodDecorator)[], | ||
79 | target: Object, | ||
80 | targetKey: string | symbol, | ||
81 | descriptor?: PropertyDescriptor): PropertyDescriptor; | ||
82 | |||
83 | function metadata(metadataKey: any, metadataValue: any): { | ||
84 | (target: Function): void; | ||
85 | (target: Object, propertyKey: string | symbol): void; | ||
86 | }; | ||
87 | function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void; | ||
88 | function defineMetadata( | ||
89 | metadataKey: any, | ||
90 | metadataValue: any, | ||
91 | target: Object, | ||
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; | ||
107 | } | ||
108 | |||
109 | |||
110 | // We need this here since there is a problem with Zone.js typings | ||
111 | interface Thenable<T> { | ||
112 | then<U>( | ||
113 | onFulfilled?: (value: T) => U | Thenable<U>, | ||
114 | onRejected?: (error: any) => U | Thenable<U>): Thenable<U>; | ||
115 | then<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>; | ||
119 | } | ||