X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fcustom-typings.d.ts;h=95787181f4cb5e03a2e377c39dab9283d2f191e0;hb=ab32b0fc805b92c5a1d7ac5901cb1a38e94622ca;hp=14c7d8aded9c4f0c5cebfbb015c7e01692be1d7a;hpb=4a6995be18b15de1834a39c8921a0e4109671bb6;p=github%2FChocobozzz%2FPeerTube.git 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 @@ /* * Custom Type Definitions * When including 3rd party modules you also need to include the type definition for the module - * if they don't provide one within the module. You can try to install it with typings + * if they don't provide one within the module. You can try to install it with @types -typings install node --save +npm install @types/node +npm install @types/lodash - * If you can't find the type definition in the registry we can make an ambient definition in + * If you can't find the type definition in the registry we can make an ambient/global definition in * this file for now. For example -declare module "my-module" { - export function doesSomething(value: string): string; +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; } * @@ -17,33 +29,65 @@ declare module "my-module" { * declare var assert: any; +declare var _: any; +declare var $: any; * * If you're importing a module that uses Node.js modules which are CommonJS you need to import as + * in the files such as main.browser.ts or any file within app/ * import * as _ from 'lodash' - * You can include your type definitions in this file until you create one for the typings registry - * see https://github.com/typings/registry + * You can include your type definitions in this file until you create one for the @types * */ +// support NodeJS modules without type definitions +declare module '*'; // Extra variables that live on Global that will be replaced by webpack DefinePlugin declare var ENV: string; declare var HMR: boolean; +declare var System: SystemJS; + +interface SystemJS { + import: (path?: string) => Promise; +} + interface GlobalEnvironment { ENV; HMR; + SystemJS: SystemJS; + System: SystemJS; } +interface Es6PromiseLoader { + (id: string): (exportName?: string) => Promise; +} + +type FactoryEs6PromiseLoader = () => Es6PromiseLoader; +type FactoryPromise = () => Promise; + +type AsyncRoutes = { + [component: string]: Es6PromiseLoader | + Function | + FactoryEs6PromiseLoader | + FactoryPromise +}; + + +type IdleCallbacks = Es6PromiseLoader | + Function | + FactoryEs6PromiseLoader | + FactoryPromise ; + interface WebpackModule { hot: { data?: any, idle: any, accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void; - decline(dependencies?: string | string[]): void; + decline(deps?: any | string | string[]): void; dispose(callback?: (data?: any) => void): void; addDisposeHandler(callback?: (data?: any) => void): void; removeDisposeHandler(callback?: (data?: any) => void): void; @@ -54,66 +98,26 @@ interface WebpackModule { }; } + interface WebpackRequire { - context(file: string, flag?: boolean, exp?: RegExp): any; + (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; } +interface WebpackContext extends WebpackRequire { + keys(): string[]; +} interface ErrorStackTraceLimit { stackTraceLimit: number; } - // Extend typings interface NodeRequire extends WebpackRequire {} interface ErrorConstructor extends ErrorStackTraceLimit {} +interface NodeRequireFunction extends Es6PromiseLoader {} interface NodeModule extends WebpackModule {} interface Global extends GlobalEnvironment {} - - -declare namespace Reflect { - function decorate(decorators: ClassDecorator[], target: Function): Function; - function decorate( - decorators: (PropertyDecorator | MethodDecorator)[], - target: Object, - targetKey: string | symbol, - descriptor?: PropertyDescriptor): PropertyDescriptor; - - function metadata(metadataKey: any, metadataValue: any): { - (target: Function): void; - (target: Object, propertyKey: string | symbol): void; - }; - function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void; - function defineMetadata( - metadataKey: any, - metadataValue: any, - target: Object, - targetKey: string | symbol): void; - function hasMetadata(metadataKey: any, target: Object): boolean; - function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; - function hasOwnMetadata(metadataKey: any, target: Object): boolean; - function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; - function getMetadata(metadataKey: any, target: Object): any; - function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; - function getOwnMetadata(metadataKey: any, target: Object): any; - function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; - function getMetadataKeys(target: Object): any[]; - function getMetadataKeys(target: Object, targetKey: string | symbol): any[]; - function getOwnMetadataKeys(target: Object): any[]; - function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[]; - function deleteMetadata(metadataKey: any, target: Object): boolean; - function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; -} - - -// We need this here since there is a problem with Zone.js typings -interface Thenable { - then( - onFulfilled?: (value: T) => U | Thenable, - onRejected?: (error: any) => U | Thenable): Thenable; - then( - onFulfilled?: (value: T) => U | Thenable, - onRejected?: (error: any) => void): Thenable; - catch(onRejected?: (error: any) => U | Thenable): Thenable; -}