From 0a57e7a1c2b03b39fbb89025146d18ec10cb0307 Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Tue, 2 Feb 2016 08:57:03 +1300 Subject: [PATCH 1/3] Add template interceptor type definition --- rest/rest-tests.ts | 2 ++ rest/rest.d.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rest/rest-tests.ts b/rest/rest-tests.ts index cedc11b00..00ce6b3db 100644 --- a/rest/rest-tests.ts +++ b/rest/rest-tests.ts @@ -13,6 +13,7 @@ import oAuth = require('rest/interceptor/oAuth'); import csrf = require('rest/interceptor/csrf'); import errorCode = require('rest/interceptor/errorCode'); import retry = require('rest/interceptor/retry'); +import template = require('rest/interceptor/template'); import timeout = require('rest/interceptor/timeout'); import jsonp = require('rest/interceptor/jsonp'); import xdomain = require('rest/interceptor/ie/xdomain'); @@ -127,6 +128,7 @@ client = rest .wrap(csrf) .wrap(errorCode) .wrap(retry) + .wrap(template, { template: 'auth={token}', params: { token: 'hunter2' } }) .wrap(timeout) .wrap(jsonp) .wrap(xdomain) diff --git a/rest/rest.d.ts b/rest/rest.d.ts index a96e0822a..ac2f2ef0b 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -1,4 +1,4 @@ -// Type definitions for rest.js v1.2.0 +// Type definitions for rest.js v1.3.1 // Project: https://github.com/cujojs/rest // Definitions by: Wim Looman // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -255,6 +255,21 @@ declare module "rest/interceptor/retry" { export = retry; } +declare module "rest/interceptor/template" { + import rest = require("rest"); + + var hateoas: rest.Interceptor; + + module template { + interface Config { + template?: string; + params?: {}; + } + } + + export = hateoas; +} + declare module "rest/interceptor/timeout" { import rest = require("rest"); From fa66ca5821f8d129152cdaa6d97248b3b3796486 Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Tue, 2 Feb 2016 09:03:41 +1300 Subject: [PATCH 2/3] Correct naming --- rest/rest.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest/rest.d.ts b/rest/rest.d.ts index ac2f2ef0b..49428d534 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -258,7 +258,7 @@ declare module "rest/interceptor/retry" { declare module "rest/interceptor/template" { import rest = require("rest"); - var hateoas: rest.Interceptor; + var template: rest.Interceptor; module template { interface Config { @@ -267,7 +267,7 @@ declare module "rest/interceptor/template" { } } - export = hateoas; + export = template; } declare module "rest/interceptor/timeout" { From cdf27e4034dc29435267a85c65b0a0809c5b9efa Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Tue, 2 Feb 2016 13:12:02 +1300 Subject: [PATCH 3/3] Fix up definition and use inference in tests where possible --- rest/rest-tests.ts | 38 +++++++++++++++++++------------------- rest/rest.d.ts | 4 +++- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/rest/rest-tests.ts b/rest/rest-tests.ts index 00ce6b3db..813a06785 100644 --- a/rest/rest-tests.ts +++ b/rest/rest-tests.ts @@ -118,25 +118,25 @@ var promiseOrResponse = interceptor({ }); client = rest - .wrap(defaultRequest) - .wrap(hateoas) - .wrap(location) - .wrap(mime) - .wrap(pathPrefix) - .wrap(basicAuth) - .wrap(oAuth) - .wrap(csrf) - .wrap(errorCode) - .wrap(retry) - .wrap(template, { template: 'auth={token}', params: { token: 'hunter2' } }) - .wrap(timeout) - .wrap(jsonp) - .wrap(xdomain) - .wrap(xhr) - .wrap(noop) - .wrap(fail) - .wrap(knownConfig, { prop: 'value' }) - .wrap(transformedConfig, { prop: 'value' }); + .wrap(defaultRequest) + .wrap(hateoas) + .wrap(location) + .wrap(mime) + .wrap(pathPrefix) + .wrap(basicAuth) + .wrap(oAuth) + .wrap(csrf) + .wrap(errorCode) + .wrap(retry) + .wrap(template, { template: 'auth={token}', params: { token: 'hunter2' } }) + .wrap(timeout) + .wrap(jsonp) + .wrap(xdomain) + .wrap(xhr) + .wrap(noop) + .wrap(fail) + .wrap(knownConfig, { prop: 'value' }) + .wrap(transformedConfig, { prop: 'value' }); import xhrClient = require('rest/client/xhr'); import nodeClient = require('rest/client/node'); diff --git a/rest/rest.d.ts b/rest/rest.d.ts index 49428d534..e000e1e93 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -263,7 +263,9 @@ declare module "rest/interceptor/template" { module template { interface Config { template?: string; - params?: {}; + params?: { + [name: string]: any; + }; } }