]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/custom-typings.d.ts
Add like/dislike system for videos
[github/Chocobozzz/PeerTube.git] / client / src / custom-typings.d.ts
... / ...
CommitLineData
1/*
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 @types
5
6npm install @types/node
7npm install @types/lodash
8
9 * If you can't find the type definition in the registry we can make an ambient/global definition in
10 * this file for now. For example
11
12declare module 'my-module' {
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;
25}
26
27 *
28 * If you're prototying and you will fix the types later you can also declare it as type any
29 *
30
31declare var assert: any;
32declare var _: any;
33declare var $: any;
34
35 *
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/
38 *
39
40import * as _ from 'lodash'
41
42 * You can include your type definitions in this file until you create one for the @types
43 *
44 */
45
46// support NodeJS modules without type definitions
47declare module '*';
48
49/*
50// for legacy tslint etc to understand rename 'modern-lru' with your package
51// then comment out `declare module '*';`. For each new module copy/paste
52// this method of creating an `any` module type definition
53declare module 'modern-lru' {
54 let x: any;
55 export = x;
56}
57*/
58
59// Extra variables that live on Global that will be replaced by webpack DefinePlugin
60declare var ENV: string;
61declare var HMR: boolean;
62declare var System: SystemJS;
63
64interface SystemJS {
65 import: (path?: string) => Promise<any>;
66}
67
68interface GlobalEnvironment {
69 ENV: string;
70 HMR: boolean;
71 SystemJS: SystemJS;
72 System: SystemJS;
73}
74
75interface Es6PromiseLoader {
76 (id: string): (exportName?: string) => Promise<any>;
77}
78
79type FactoryEs6PromiseLoader = () => Es6PromiseLoader;
80type FactoryPromise = () => Promise<any>;
81
82type AsyncRoutes = {
83 [component: string]: Es6PromiseLoader |
84 Function |
85 FactoryEs6PromiseLoader |
86 FactoryPromise
87};
88
89type IdleCallbacks = Es6PromiseLoader |
90 Function |
91 FactoryEs6PromiseLoader |
92 FactoryPromise ;
93
94interface WebpackModule {
95 hot: {
96 data?: any,
97 idle: any,
98 accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
99 decline(deps?: any | string | string[]): void;
100 dispose(callback?: (data?: any) => void): void;
101 addDisposeHandler(callback?: (data?: any) => void): void;
102 removeDisposeHandler(callback?: (data?: any) => void): void;
103 check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
104 apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
105 status(callback?: (status?: string) => void): void | string;
106 removeStatusHandler(callback?: (status?: string) => void): void;
107 };
108}
109
110interface WebpackRequire {
111 (id: string): any;
112 (paths: string[], callback: (...modules: any[]) => void): void;
113 ensure(ids: string[], callback: (req: WebpackRequire) => void, chunkName?: string): void;
114 context(directory: string, useSubDirectories?: boolean, regExp?: RegExp): WebpackContext;
115}
116
117interface WebpackContext extends WebpackRequire {
118 keys(): string[];
119}
120
121interface ErrorStackTraceLimit {
122 stackTraceLimit: number;
123}
124
125// Extend typings
126interface NodeRequire extends WebpackRequire {}
127interface ErrorConstructor extends ErrorStackTraceLimit {}
128interface NodeRequireFunction extends Es6PromiseLoader {}
129interface NodeModule extends WebpackModule {}
130interface Global extends GlobalEnvironment {}