From e4b2ebe7aaaa8afe9ca775bde51679fba20fc09c Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 6 Dec 2024 23:29:21 +0100 Subject: [PATCH] fix: replace 'any' with specific types --- src/app/core/data/base/base-data.service.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/app/core/data/base/base-data.service.ts b/src/app/core/data/base/base-data.service.ts index 2146ba2475..2d4eceb41b 100644 --- a/src/app/core/data/base/base-data.service.ts +++ b/src/app/core/data/base/base-data.service.ts @@ -40,7 +40,6 @@ import { ObjectCacheService } from '../../cache/object-cache.service'; import { GenericConstructor } from '../../shared/generic-constructor'; import { HALEndpointService } from '../../shared/hal-endpoint.service'; import { HALLink } from '../../shared/hal-link.model'; -import { HALResource } from '../../shared/hal-resource.model'; import { getFirstCompletedRemoteData } from '../../shared/operators'; import { URLCombiner } from '../../url-combiner/url-combiner'; import { FindListOptions } from '../find-list-options.model'; @@ -307,9 +306,9 @@ export class BaseDataService implements HALDataServic // Ensure all followLinks from the cached object are automatically invalidated when invalidating the cached object tap((remoteDataObject: RemoteData) => { if (hasValue(remoteDataObject?.payload?._links)) { - for (const followLinkName of Object.keys(remoteDataObject.payload._links)) { + for (const followLinkName of Object.keys(remoteDataObject.payload._links) as (keyof typeof remoteDataObject.payload._links)[]) { // only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name - const linkDefinition = this.getLinkDefinition((remoteDataObject.payload as any).constructor, followLinkName); + const linkDefinition: LinkDefinition = getLinkDefinition(remoteDataObject.payload.constructor as GenericConstructor, followLinkName); if (linkDefinition?.propertyName && hasValue(remoteDataObject.payload[linkDefinition.propertyName]) && followLinkName !== 'self') { // followLink can be either an individual HALLink or a HALLink[] const followLinksList: HALLink[] = [].concat(remoteDataObject.payload._links[followLinkName]); @@ -364,9 +363,9 @@ export class BaseDataService implements HALDataServic if (hasValue(remoteDataObject?.payload?.page)) { for (const object of remoteDataObject.payload.page) { if (hasValue(object?._links)) { - for (const followLinkName of Object.keys(object._links)) { + for (const followLinkName of Object.keys(object._links) as (keyof typeof object._links)[]) { // only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name - const linkDefinition = this.getLinkDefinition((remoteDataObject.payload as any).constructor, followLinkName); + const linkDefinition: LinkDefinition> = getLinkDefinition(remoteDataObject.payload.constructor as GenericConstructor>, followLinkName); if (linkDefinition?.propertyName && followLinkName !== 'self' && hasValue(object[linkDefinition.propertyName])) { // followLink can be either an individual HALLink or a HALLink[] const followLinksList: HALLink[] = [].concat(object._links[followLinkName]); @@ -522,9 +521,4 @@ export class BaseDataService implements HALDataServic return done$; } - - getLinkDefinition(source: GenericConstructor, linkName: keyof D['_links']): LinkDefinition { - return getLinkDefinition(source, linkName); - } - }