diff --git a/rest/rest-tests.ts b/rest/rest-tests.ts index f291e53c0..905084318 100644 --- a/rest/rest-tests.ts +++ b/rest/rest-tests.ts @@ -91,12 +91,18 @@ interface KnownConfig { prop: string; } var knownConfig = interceptor({ - init: (config: KnownConfig) => { - config.prop = config.prop || 'default-value'; - return config; - }, success: (response: rest.Response, config: KnownConfig) => { - console.log(config.prop); + console.log(config); + return response; + }, +}); + +var transformedConfig = interceptor({ + init: (config: KnownConfig) => { + return config.prop; + }, + success: (response: rest.Response, config: string) => { + console.log(config); return response; }, }); @@ -127,4 +133,5 @@ client = rest .wrap(xhr) .wrap(noop) .wrap(fail) - .wrap(knownConfig, { prop: 'value' }); + .wrap(knownConfig, { prop: 'value' }) + .wrap(transformedConfig, { prop: 'value' }); diff --git a/rest/rest.d.ts b/rest/rest.d.ts index 98c214537..ef7fc2abf 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -71,15 +71,15 @@ declare module "rest/interceptor" { import when = require("when"); import rest = require("rest"); - function interceptor(config: interceptor.Config): rest.Interceptor; + function interceptor(config: interceptor.Config): rest.Interceptor; module interceptor { - interface Config { - init?: (config: T) => T; - request?: (request: rest.Request, config: T, meta: rest.Meta) => rest.Request | when.Promise; - response?: (response: rest.Response, config: T, meta: rest.Meta) => rest.Response | when.Promise; - success?: (response: rest.Response, config: T, meta: rest.Meta) => rest.Response | when.Promise; - error?: (response: rest.Response, config: T, meta: rest.Meta) => rest.Response | when.Promise; + interface Config { + init?: (config: T) => U; + request?: (request: rest.Request, config: U, meta: rest.Meta) => rest.Request | when.Promise; + response?: (response: rest.Response, config: U, meta: rest.Meta) => rest.Response | when.Promise; + success?: (response: rest.Response, config: U, meta: rest.Meta) => rest.Response | when.Promise; + error?: (response: rest.Response, config: U, meta: rest.Meta) => rest.Response | when.Promise; } }