chore: fix types
This commit is contained in:
parent
d79795acc3
commit
570f834b85
2 changed files with 17 additions and 9 deletions
|
|
@ -72,14 +72,19 @@ export class Ajax {
|
||||||
this.addRequestInterceptor(createXsrfRequestInterceptor(xsrfCookieName, xsrfHeaderName));
|
this.addRequestInterceptor(createXsrfRequestInterceptor(xsrfCookieName, xsrfHeaderName));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cacheOptions } = this.__config;
|
// eslint-disable-next-line prefer-destructuring
|
||||||
if (cacheOptions.useCache || this.__config.addCaching) {
|
const cacheOptions = /** @type {import('@lion/ajax').CacheOptionsWithIdentifier} */ (
|
||||||
const { cacheRequestInterceptor, cacheResponseInterceptor } = createCacheInterceptors(
|
this.__config.cacheOptions
|
||||||
cacheOptions.getCacheIdentifier,
|
);
|
||||||
cacheOptions,
|
if ((cacheOptions && cacheOptions.useCache) || this.__config.addCaching) {
|
||||||
);
|
if (cacheOptions.getCacheIdentifier) {
|
||||||
this.addRequestInterceptor(cacheRequestInterceptor);
|
const { cacheRequestInterceptor, cacheResponseInterceptor } = createCacheInterceptors(
|
||||||
this.addResponseInterceptor(cacheResponseInterceptor);
|
cacheOptions.getCacheIdentifier,
|
||||||
|
cacheOptions,
|
||||||
|
);
|
||||||
|
this.addRequestInterceptor(cacheRequestInterceptor);
|
||||||
|
this.addResponseInterceptor(cacheResponseInterceptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,10 @@ describe('Ajax', () => {
|
||||||
// TODO: fix AjaxConfig types => e.g. create FullAjaxConfig with everything "mandatory" and then AjaxConfig (= Partial of it) for user
|
// TODO: fix AjaxConfig types => e.g. create FullAjaxConfig with everything "mandatory" and then AjaxConfig (= Partial of it) for user
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const ajax1 = new Ajax(config);
|
const ajax1 = new Ajax(config);
|
||||||
const defaultCacheIdentifierFunction = ajax1.options?.cacheOptions?.getCacheIdentifier;
|
|
||||||
|
const defaultCacheIdentifierFunction = /** @type {() => void} */ (
|
||||||
|
ajax1.options?.cacheOptions?.getCacheIdentifier
|
||||||
|
);
|
||||||
// Then
|
// Then
|
||||||
expect(defaultCacheIdentifierFunction).not.to.be.undefined;
|
expect(defaultCacheIdentifierFunction).not.to.be.undefined;
|
||||||
expect(defaultCacheIdentifierFunction).to.be.a('function');
|
expect(defaultCacheIdentifierFunction).to.be.a('function');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue