aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/custom-typings.d.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
commita6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch)
tree03204a408d56311692c3528bedcf95d2455e94f2 /client/src/custom-typings.d.ts
parent052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff)
parentc4403b29ad4db097af528a7f04eea07e0ed320d0 (diff)
downloadPeerTube-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.ts118
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
6typings install node --save 6npm install @types/node
7npm 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
11declare module "my-module" { 12declare 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
21declare 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
19declare var assert: any; 31declare var assert: any;
32declare var _: any;
33declare 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
25import * as _ from 'lodash' 40import * 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
47declare 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
34declare var ENV: string; 50declare var ENV: string;
35declare var HMR: boolean; 51declare var HMR: boolean;
52declare var System: SystemJS;
53
54interface SystemJS {
55 import: (path?: string) => Promise<any>;
56}
57
36interface GlobalEnvironment { 58interface GlobalEnvironment {
37 ENV; 59 ENV;
38 HMR; 60 HMR;
61 SystemJS: SystemJS;
62 System: SystemJS;
39} 63}
40 64
65interface Es6PromiseLoader {
66 (id: string): (exportName?: string) => Promise<any>;
67}
68
69type FactoryEs6PromiseLoader = () => Es6PromiseLoader;
70type FactoryPromise = () => Promise<any>;
71
72type AsyncRoutes = {
73 [component: string]: Es6PromiseLoader |
74 Function |
75 FactoryEs6PromiseLoader |
76 FactoryPromise
77};
78
79
80type IdleCallbacks = Es6PromiseLoader |
81 Function |
82 FactoryEs6PromiseLoader |
83 FactoryPromise ;
84
41interface WebpackModule { 85interface 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
57interface WebpackRequire { 102interface 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
109interface WebpackContext extends WebpackRequire {
110 keys(): string[];
111}
61 112
62interface ErrorStackTraceLimit { 113interface ErrorStackTraceLimit {
63 stackTraceLimit: number; 114 stackTraceLimit: number;
64} 115}
65 116
66 117
67
68// Extend typings 118// Extend typings
69interface NodeRequire extends WebpackRequire {} 119interface NodeRequire extends WebpackRequire {}
70interface ErrorConstructor extends ErrorStackTraceLimit {} 120interface ErrorConstructor extends ErrorStackTraceLimit {}
121interface NodeRequireFunction extends Es6PromiseLoader {}
71interface NodeModule extends WebpackModule {} 122interface NodeModule extends WebpackModule {}
72interface Global extends GlobalEnvironment {} 123interface Global extends GlobalEnvironment {}
73
74
75declare 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
111interface 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}