From 7e3bc700b3e9f9ada0dc5f36c2b52bb51a23ec11 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Wed, 6 Jan 2016 17:29:37 +0100 Subject: [PATCH 1/8] Add definition for "i18next-express-middleware". --- .../i18next-express-middleware-tests.ts | 5 +++ .../i18next-express-middleware.d.ts | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 i18next-express-middleware/i18next-express-middleware-tests.ts create mode 100644 i18next-express-middleware/i18next-express-middleware.d.ts diff --git a/i18next-express-middleware/i18next-express-middleware-tests.ts b/i18next-express-middleware/i18next-express-middleware-tests.ts new file mode 100644 index 000000000..54e47b03c --- /dev/null +++ b/i18next-express-middleware/i18next-express-middleware-tests.ts @@ -0,0 +1,5 @@ +/// + +//import express = require("express"); +//import i18next = require("i18next"); +import middleware = require("i18next-express-middleware"); diff --git a/i18next-express-middleware/i18next-express-middleware.d.ts b/i18next-express-middleware/i18next-express-middleware.d.ts new file mode 100644 index 000000000..ad9f0a95d --- /dev/null +++ b/i18next-express-middleware/i18next-express-middleware.d.ts @@ -0,0 +1,33 @@ +// Type definitions for i18next-express-middleware +// Project: http://i18next.com/ +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "i18next-express-middleware" { + import express = require("express"); + export interface i18nextExpressMiddleware { + LanguageDetector(): express.Handler; + missingKeyHandler(): express.Handler; + } + + interface LanguageDetectorOptions { + caches: boolean; + cookieDomain: string; + cookieExpirationDate: Date; + lookupCookie: string; + lookupFromPathIndex: number; + lookupQuerystring: string; + lookupSession: string; + order: Array; + } + + export class LanguageDetector { + constructor(services?: any, options?: Object, allOptions?: Object); + addDetector(detector: any): void; + cacheUserLanguage(req: express.Request, res: express.Response, detectionOrder: any): void; + detect(req: express.Request, res: express.Response, detectionOrder: any): void; + init(services: any, options?: Object, allOptions?: Object): void; + } +} From 5f2a5d25bbf64562561aeb3055b4ea6fbd27716f Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 7 Jan 2016 16:23:33 +0100 Subject: [PATCH 2/8] Update definitions for "i18next-express-middleware", "i18next" and "connect-timeout". Remove "tscparams" file for "acc-wizard". --- acc-wizard/acc-wizard.ts.tscparams | 1 - connect-timeout/connect-timeout-tests.ts | 8 +- connect-timeout/connect-timeout.d.ts | 7 +- .../i18next-express-middleware-tests.ts | 47 ++++++++++- .../i18next-express-middleware.d.ts | 83 ++++++++++++++++--- i18next/i18next.d.ts | 7 +- 6 files changed, 132 insertions(+), 21 deletions(-) delete mode 100644 acc-wizard/acc-wizard.ts.tscparams diff --git a/acc-wizard/acc-wizard.ts.tscparams b/acc-wizard/acc-wizard.ts.tscparams deleted file mode 100644 index 934bc29ef..000000000 --- a/acc-wizard/acc-wizard.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ ---noImplicitAny \ No newline at end of file diff --git a/connect-timeout/connect-timeout-tests.ts b/connect-timeout/connect-timeout-tests.ts index 920c7fdc6..4f77b597d 100644 --- a/connect-timeout/connect-timeout-tests.ts +++ b/connect-timeout/connect-timeout-tests.ts @@ -3,10 +3,10 @@ /// /// -import express = require("express"); -import timeout = require("connect-timeout"); -import bodyParser = require("body-parser"); -import cookieParser = require("cookie-parser"); +import * as express from "express"; +import timeout from "connect-timeout"; +import * as bodyParser from "body-parser"; +import * as cookieParser from "cookie-parser"; // example of using this top-level; note the use of haltOnTimedout // after every middleware; it will stop the request flow on a timeout diff --git a/connect-timeout/connect-timeout.d.ts b/connect-timeout/connect-timeout.d.ts index 8494a3afb..88bafbad5 100644 --- a/connect-timeout/connect-timeout.d.ts +++ b/connect-timeout/connect-timeout.d.ts @@ -23,6 +23,10 @@ declare module Express { declare module "connect-timeout" { import express = require("express"); + /** + * @summary Interface for timeout options. + * @interface + */ interface TimeoutOptions extends Object { /** * @summary Controls if this module will "respond" in the form of forwarding an error. @@ -31,6 +35,5 @@ declare module "connect-timeout" { respond: boolean; } - function timeout(timeout: string, options?: TimeoutOptions): express.RequestHandler; - export = timeout; + export default function timeout(timeout: string, options?: TimeoutOptions): express.RequestHandler; } diff --git a/i18next-express-middleware/i18next-express-middleware-tests.ts b/i18next-express-middleware/i18next-express-middleware-tests.ts index 54e47b03c..a696f4f8a 100644 --- a/i18next-express-middleware/i18next-express-middleware-tests.ts +++ b/i18next-express-middleware/i18next-express-middleware-tests.ts @@ -1,5 +1,48 @@ +/// /// -//import express = require("express"); -//import i18next = require("i18next"); +import * as express from "express"; +import * as i18next from "i18next"; import middleware = require("i18next-express-middleware"); + +function requestObjectTest() { + var i18nextOptions = {}; + i18next + .use(middleware.LanguageDetector) + .init(i18nextOptions); + + var app = express(); + app.use(middleware.handle(i18next, { + ignoreRoutes: ["/foo"], + removeLngFromUrl: false + })); +} + +function detectorOptionsTest() { + var options = { + // order and from where user language should be detected + order: [/*'path', 'session', */ 'querystring', 'cookie', 'header'], + + // keys or params to lookup language from + lookupQuerystring: 'lng', + lookupCookie: 'i18next', + lookupSession: 'lng', + lookupFromPathIndex: 0, + + // cache user language + caches: false, // ['cookie'] + + // optional expire and domain for set cookie + cookieExpirationDate: new Date(), + cookieDomain: 'myDomain' + }; + + i18next + .use(middleware.LanguageDetector) + .init({ + detection: options + }); + + var lngDetector = new middleware.LanguageDetector(null, options); + lngDetector.init(options); +} diff --git a/i18next-express-middleware/i18next-express-middleware.d.ts b/i18next-express-middleware/i18next-express-middleware.d.ts index ad9f0a95d..fe51928bf 100644 --- a/i18next-express-middleware/i18next-express-middleware.d.ts +++ b/i18next-express-middleware/i18next-express-middleware.d.ts @@ -4,30 +4,93 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// + +/** + * @summary Interface for Language detector options. + * @interface + */ +interface LanguageDetectorOptions { + caches?: boolean; + cookieDomain?: string; + cookieExpirationDate?: Date; + lookupCookie?: string; + lookupFromPathIndex?: number; + lookupQuerystring?: string; + lookupSession?: string; + order?: Array; +} declare module "i18next-express-middleware" { import express = require("express"); + import i18next = require("i18next"); + + /** + * @summary Interface for middleware to use i18next in express.js. + * @interface + */ export interface i18nextExpressMiddleware { LanguageDetector(): express.Handler; missingKeyHandler(): express.Handler; } - interface LanguageDetectorOptions { - caches: boolean; - cookieDomain: string; - cookieExpirationDate: Date; - lookupCookie: string; - lookupFromPathIndex: number; - lookupQuerystring: string; - lookupSession: string; - order: Array; + /** + * @summary Interface for own detection functionality. + */ + export interface i18nextCustomDetection { + name: string; + lookup: (req: express.Request, res: express.Response, options?: Object) => void; + cacheUserLanguage: (req: express.Request, res: express.Response, lng?: any, options?: Object) => void; } + /** + * @summary Detects user language from current request. + * @class + */ export class LanguageDetector { + /** + * @summary Constructor. + * @constructor + * @param {any} services The services. + * @param {Object} options The options. + * @param {Object} allOptions The all options. + */ constructor(services?: any, options?: Object, allOptions?: Object); - addDetector(detector: any): void; + + /** + * @summary Adds detector. + * @param {i18nextCustomDetection} detector The detector to add. + */ + addDetector(detector: i18nextCustomDetection): void; + + // NOTE: add documentation cacheUserLanguage(req: express.Request, res: express.Response, detectionOrder: any): void; + + /** + * @summary Detects the language. + * @param {Request} req The HTTP request. + * @param {Response} res The HTTP response. + * @param {detectionOrder} detectionOrder The detection order. + */ detect(req: express.Request, res: express.Response, detectionOrder: any): void; + + /** + * @summary Initializes class. + * @param {any} services The services. + * @param {Object} options The options. + * @param {Object} allOptions The all options. + */ init(services: any, options?: Object, allOptions?: Object): void; } + + export function getResourcesHandler(i18next: I18nextStatic, options: Object): express.Handler; + export function handle(i18next: I18nextStatic, options?: Object): express.Handler; + + /** + * @summary Gets handler for missing key. + * @param {I18nextStatic} i18next The i18next. + * @param {Object} options The options. + * @return {express.Handler} The express handler. + */ + export function missingKeyHandler(i18next: I18nextStatic, options: Object): express.Handler; } diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 38d91b603..9256e7a45 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -1,11 +1,13 @@ -// Type definitions for i18next v1.5.10 +// Type definitions for i18next v2.0.17 // Project: http://i18next.com // Definitions by: Maarten Docter // Definitions: https://github.com/borisyankov/DefinitelyTyped // Sources: https://github.com/jamuhl/i18next/ +/// /// +/// interface IResourceStore { [language: string]: IResourceStoreLanguage; @@ -99,7 +101,7 @@ interface I18nextStatic { regexEscape(str: string): string; }; init(callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred; - init(options?: I18nextOptions, callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred; + init(options?: I18nextOptions|any, callback?: (err: any, t: (key: string, options?: any) => string) => void ): JQueryDeferred; // NOTE: remove any for 'options' parameter. lng(): string; loadNamespace(namespace: string, callback?: () => void ): void; loadNamespaces(namespaces: string[], callback?: () => void ): void; @@ -124,6 +126,7 @@ interface I18nextStatic { t(key: string, options?: I18nTranslateOptions): string; translate(key: string, options?: I18nTranslateOptions): string; exists(key: string, options?: any): boolean; + use(module: any): I18nextStatic; } // jQuery extensions From 257f49655e4d680029ea0f45b3c8b7a8b6658b70 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 19:17:06 +0100 Subject: [PATCH 3/8] Add options for "express-brute". Add definition for "i18next-sprintf-postprocessor". --- express-brute/express-brute.d.ts | 148 ++++++++++-------- .../i18next-sprintf-postProcessor-tests.ts | 10 ++ .../i18next-sprintf-postProcessor.d.ts | 17 ++ i18next/i18next.d.ts | 9 +- 4 files changed, 117 insertions(+), 67 deletions(-) create mode 100644 i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts create mode 100644 i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts diff --git a/express-brute/express-brute.d.ts b/express-brute/express-brute.d.ts index 7242d44dc..1e672fdfb 100644 --- a/express-brute/express-brute.d.ts +++ b/express-brute/express-brute.d.ts @@ -45,85 +45,101 @@ declare module "express-brute" { } /** - * @summary Middleware. + * @summary Options for {@link ExpressBrute} class. + * @interface + */ + interface ExpressBruteOptions { + freeRetries: number; + proxyDepth: number; + attachResetToRequest: boolean; + refreshTimeoutOnRequest: boolean; + minWait: number; + maxWait: number; + lifetime: number; + failCallback: (req: express.Request, res: express.Response, next: Function, nextValidRequestDate: any) => void; + handleStoreError: any; +} + +/** + * @summary Middleware. + * @class + */ +class ExpressBrute { + /** + * @summary Constructor. + * @constructor + * @param {any} store The store. + */ + constructor(store: any); + + /** + * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. + * @param {Object} options The options. + */ + getMiddleware(options: ExpressBruteMiddleware): express.RequestHandler; + + /** + * @summary Uses the current proxy trust settings to get the current IP from a request object. + * @param {Request} request The HTTP request. + * @return {RequestHandler} The Request handler. + */ + getIPFromRequest(request: express.Request): express.RequestHandler; + + /** + * @summary Middleware that will bounce requests that happen faster than the current wait time by calling failCallback. + * @param {Request} request The HTTP request. + * @param {Response} response The HTTP response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + prevent(request: express.Request, response: express.Response, next: Function): express.RequestHandler; + + /** + * @summary Resets the wait time between requests back to its initial value. + * @param {string} ip The IP address. + * @param {string} key The key. response. + * @param {Function} next The next middleware. + * @return {RequestHandler} The Request handler. + */ + reset(ip: string, key: string, next: Function): express.RequestHandler; +} + +module ExpressBrute { + /** + * @summary In-memory store. * @class */ - class ExpressBrute { + export class MemoryStore { /** * @summary Constructor. * @constructor - * @param {any} store The store. - */ - constructor(store: any); - - /** - * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. * @param {Object} options The options. */ - getMiddleware(options: ExpressBruteMiddleware): express.RequestHandler; + constructor(options?: MemoryStoreOptions); + /** + * @summary Gets key value. + * @param {string} key The key name. + * @param {Function} callbck The callback. + */ + get(key: string, callback: (error: any, data: Object) => void): void; /** - * @summary Uses the current proxy trust settings to get the current IP from a request object. - * @param {Request} request The HTTP request. - * @return {RequestHandler} The Request handler. + * @summary Sets the key value. + * @param {string} key The name. + * @param {string} value The value. + * @param {number} lifetime The lifetime. + * @param {Function} callback The callback. */ - getIPFromRequest(request: express.Request): express.RequestHandler; + set(key: string, value: any, lifetime: number, callback: (error: any) => void): void; /** - * @summary Middleware that will bounce requests that happen faster than the current wait time by calling failCallback. - * @param {Request} request The HTTP request. - * @param {Response} response The HTTP response. - * @param {Function} next The next middleware. - * @return {RequestHandler} The Request handler. + * @summary Deletes the key. + * @param {string} key The name. + * @param {Function} callback The callback. */ - prevent(request: express.Request, response: express.Response, next: Function): express.RequestHandler; - - /** - * @summary Resets the wait time between requests back to its initial value. - * @param {string} ip The IP address. - * @param {string} key The key. response. - * @param {Function} next The next middleware. - * @return {RequestHandler} The Request handler. - */ - reset(ip: string, key: string, next: Function): express.RequestHandler; + reset(key: string, callback: (error: any) => void): void; } +} - module ExpressBrute { - /** - * @summary In-memory store. - * @class - */ - export class MemoryStore { - /** - * @summary Constructor. - * @constructor - * @param {Object} options The options. - */ - constructor(options?: MemoryStoreOptions); - /** - * @summary Gets key value. - * @param {string} key The key name. - * @param {Function} callbck The callback. - */ - get(key: string, callback: (error: any, data: Object) => void): void; - - /** - * @summary Sets the key value. - * @param {string} key The name. - * @param {string} value The value. - * @param {number} lifetime The lifetime. - * @param {Function} callback The callback. - */ - set(key: string, value: any, lifetime: number, callback: (error: any) => void): void; - - /** - * @summary Deletes the key. - * @param {string} key The name. - * @param {Function} callback The callback. - */ - reset(key: string, callback: (error: any) => void): void; - } - } - - export = ExpressBrute; +export = ExpressBrute; } diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts new file mode 100644 index 000000000..a28aec01f --- /dev/null +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts @@ -0,0 +1,10 @@ +/// + +import * as i18next from "i18next"; +import sprintf from "i18next-sprintf-postprocessor"; + +function initTest() { + const i18nextOptions = {}; + i18next.use(sprintf).init(i18nextOptions); + i18next.init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler }); +} diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts new file mode 100644 index 000000000..838cd0311 --- /dev/null +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts @@ -0,0 +1,17 @@ +// Type definitions for i18next-sprintf-postProcessor +// Project: https://github.com/i18next/i18next-sprintf-postProcessor +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "i18next-sprintf-postprocessor" { + import i18next = require("i18next"); + + export default interface i18nextSprintfPostProcessor { + process(value: any, key: string, options: Object): void; + overloadTranslationOptionHandler(args: Array): void; + } + //export default function sprintf(): any; +} diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 9256e7a45..4a20978ff 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -8,6 +8,7 @@ /// /// /// +/// interface IResourceStore { [language: string]: IResourceStoreLanguage; @@ -29,7 +30,11 @@ interface I18nTranslateOptions extends I18nextOptions { context?: any; } -interface I18nextOptions { +interface i18nextSprintfPostProcessorStatic { + overloadTranslationOptionHandler: any; +} + +interface I18nextOptions extends i18nextSprintfPostProcessorStatic { lng?: string; // Default value: undefined load?: string; // Default value: 'all' preload?: string[]; // Default value: [] @@ -77,6 +82,8 @@ interface I18nextOptions { // NOTE https://github.com/borisyankov/DefinitelyTyped/pull/5590 replace?: any; + + overloadTranslationOptionHandler: (args: Array) => void; } interface I18nextStatic { From 8539f595da9fb3164d9bf756b2510122fc1cb534 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 19:19:31 +0100 Subject: [PATCH 4/8] Rename files. --- ...tProcessor-tests.ts => i18next-sprintf-postprocessor-tests.ts} | 0 ...intf-postProcessor.d.ts => i18next-sprintf-postprocessor.d.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename i18next-sprintf-postprocessor/{i18next-sprintf-postProcessor-tests.ts => i18next-sprintf-postprocessor-tests.ts} (100%) rename i18next-sprintf-postprocessor/{i18next-sprintf-postProcessor.d.ts => i18next-sprintf-postprocessor.d.ts} (100%) diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts similarity index 100% rename from i18next-sprintf-postprocessor/i18next-sprintf-postProcessor-tests.ts rename to i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts similarity index 100% rename from i18next-sprintf-postprocessor/i18next-sprintf-postProcessor.d.ts rename to i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts From 087195bc97589786f4adc61f16835b83d6aa8729 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 19:34:46 +0100 Subject: [PATCH 5/8] Add definition for "express-brute-memcached". --- .../express-brute-memcached-tests.ts | 18 +++ .../express-brute-memcached.d.ts | 114 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 express-brute-memcached/express-brute-memcached-tests.ts create mode 100644 express-brute-memcached/express-brute-memcached.d.ts diff --git a/express-brute-memcached/express-brute-memcached-tests.ts b/express-brute-memcached/express-brute-memcached-tests.ts new file mode 100644 index 000000000..a8d777090 --- /dev/null +++ b/express-brute-memcached/express-brute-memcached-tests.ts @@ -0,0 +1,18 @@ +/// +/// +/// + +import express = require("express"); +import ExpressBrute = require("express-brute"); +import MemcachedStore = require("express-brute-memcached"); + +var app = express(); +var store = new MemcachedStore("127.0.0.1"); +var bruteforce = new ExpressBrute(store); + +app.post('/auth', + bruteforce.prevent, // error 403 if we hit this route too often + function (req, res, next) { + res.send('Success!'); + } +); diff --git a/express-brute-memcached/express-brute-memcached.d.ts b/express-brute-memcached/express-brute-memcached.d.ts new file mode 100644 index 000000000..4ef41cd69 --- /dev/null +++ b/express-brute-memcached/express-brute-memcached.d.ts @@ -0,0 +1,114 @@ +// Type definitions for express-brute-memcached +// Project: https://github.com/AdamPflug/express-brute-memcached +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "express-brute-memcached" { + /** + * @summary Memcached options. + * @interface + */ + interface MemcachedStoreOptions { + prefix: string; + + /** + * @summary Maximum key size allowed. + * @type {number} + */ + maxKeySize: number; + + /** + * @summary Maximum expiration time of keys (in seconds). + * @type {number} + */ + maxExpiration: number; + + /** + * @summary Maximum size of a value. + * @type {number} + */ + maxValue: number; + + /** + * @summary Maximum size of the connection pool. + * @type {number} + */ + poolSize: number; + + /** + * @summary Hashing algorithm used to generate the hashRing values + * @type {string} + */ + algorithm: string; + + /** + * @summary Time between reconnection attempts (in milliseconds). + * @type {number} + */ + reconnect: number; + + /** + * @summary Time after which Memcached sends a connection timeout (in milliseconds). + * @type {number} + */ + timeout: number; + + /** + * @summary Number of socket allocation retries per request. + * @type {number} + */ + retries: number; + + /** + * @summary Number of failed-attempts to a server before it is regarded as 'dead'. + * @type {number} + */ + failures: number; + + /** + * @summary Time between a server failure and an attempt to set it up back in service. + * @type {number} + */ + retry: number; + + /** + * @summary If true, authorizes the automatic removal of dead servers from the pool. + * @type {boolean} + */ + remove: boolean; + + /** + * @summary An array of server_locations to replace servers that fail and that are removed from the consistent hashing scheme. + * @type {Array} + */ + failOverServers: Array; + + /** + * @summary True, whether to use md5 as hashing scheme when keys exceed maxKeySize . + * @type + */ + keyCompression: boolean; + + /** + * @summary Idle timeout for the connections. + * @type {number} + */ + idle: number; + } + + /** + * @summary A memcached store adapter. + * @class + */ + export = class MemcachedStore { + /** + * @summary Constructor. + * @constructor + * @param {string|Array} hosts The collection. + * @param {Object} options The otpions. + */ + constructor(hosts: string|Array, options?: MemcachedStoreOptions); + } +} From 61b120cc79f2dd3ab8cac60ba922e5839f6a42cd Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 19:51:12 +0100 Subject: [PATCH 6/8] Update definitions for "i18next" and "i18next-sprintf-postprecessor". --- .../i18next-sprintf-postprocessor.d.ts | 7 +++++-- i18next/i18next.d.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts index 838cd0311..7983e46aa 100644 --- a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts @@ -9,9 +9,12 @@ declare module "i18next-sprintf-postprocessor" { import i18next = require("i18next"); - export default interface i18nextSprintfPostProcessor { + interface i18nextSprintfPostProcessor { + (): any; process(value: any, key: string, options: Object): void; overloadTranslationOptionHandler(args: Array): void; } - //export default function sprintf(): any; + + var sprintf: i18nextSprintfPostProcessor; + export default sprintf; } diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 4a20978ff..9bd5aec50 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -31,7 +31,8 @@ interface I18nTranslateOptions extends I18nextOptions { } interface i18nextSprintfPostProcessorStatic { - overloadTranslationOptionHandler: any; + overloadTranslationOptionHandler(args: Array): void; + process(value: any, key: string, options: Object): void; } interface I18nextOptions extends i18nextSprintfPostProcessorStatic { From 223d9bcb01a72c0e7df74a571b48ed308f7e91db Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 19:55:18 +0100 Subject: [PATCH 7/8] Fix error. --- i18next/i18next.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 9bd5aec50..c9a215953 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -31,8 +31,8 @@ interface I18nTranslateOptions extends I18nextOptions { } interface i18nextSprintfPostProcessorStatic { - overloadTranslationOptionHandler(args: Array): void; - process(value: any, key: string, options: Object): void; + overloadTranslationOptionHandler?(args: Array): void; + process?(value: any, key: string, options: Object): void; } interface I18nextOptions extends i18nextSprintfPostProcessorStatic { @@ -83,8 +83,6 @@ interface I18nextOptions extends i18nextSprintfPostProcessorStatic { // NOTE https://github.com/borisyankov/DefinitelyTyped/pull/5590 replace?: any; - - overloadTranslationOptionHandler: (args: Array) => void; } interface I18nextStatic { From 0fb447c5e7ba793d6f6c6c1414d3fc470726b631 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 14 Jan 2016 20:03:06 +0100 Subject: [PATCH 8/8] Fix reference path. --- .../i18next-sprintf-postprocessor-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts index a28aec01f..b2bdf3b8d 100644 --- a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts @@ -1,4 +1,4 @@ -/// +/// import * as i18next from "i18next"; import sprintf from "i18next-sprintf-postprocessor";