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));
|
||||
}
|
||||
|
||||
const { cacheOptions } = this.__config;
|
||||
if (cacheOptions.useCache || this.__config.addCaching) {
|
||||
const { cacheRequestInterceptor, cacheResponseInterceptor } = createCacheInterceptors(
|
||||
cacheOptions.getCacheIdentifier,
|
||||
cacheOptions,
|
||||
);
|
||||
this.addRequestInterceptor(cacheRequestInterceptor);
|
||||
this.addResponseInterceptor(cacheResponseInterceptor);
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
const cacheOptions = /** @type {import('@lion/ajax').CacheOptionsWithIdentifier} */ (
|
||||
this.__config.cacheOptions
|
||||
);
|
||||
if ((cacheOptions && cacheOptions.useCache) || this.__config.addCaching) {
|
||||
if (cacheOptions.getCacheIdentifier) {
|
||||
const { cacheRequestInterceptor, cacheResponseInterceptor } = createCacheInterceptors(
|
||||
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
|
||||
// @ts-ignore
|
||||
const ajax1 = new Ajax(config);
|
||||
const defaultCacheIdentifierFunction = ajax1.options?.cacheOptions?.getCacheIdentifier;
|
||||
|
||||
const defaultCacheIdentifierFunction = /** @type {() => void} */ (
|
||||
ajax1.options?.cacheOptions?.getCacheIdentifier
|
||||
);
|
||||
// Then
|
||||
expect(defaultCacheIdentifierFunction).not.to.be.undefined;
|
||||
expect(defaultCacheIdentifierFunction).to.be.a('function');
|
||||
|
|
|
|||
Loading…
Reference in a new issue