Skip to content

Commit e4b2ebe

Browse files
fix: replace 'any' with specific types
1 parent 2fb746f commit e4b2ebe

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/app/core/data/base/base-data.service.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { ObjectCacheService } from '../../cache/object-cache.service';
4040
import { GenericConstructor } from '../../shared/generic-constructor';
4141
import { HALEndpointService } from '../../shared/hal-endpoint.service';
4242
import { HALLink } from '../../shared/hal-link.model';
43-
import { HALResource } from '../../shared/hal-resource.model';
4443
import { getFirstCompletedRemoteData } from '../../shared/operators';
4544
import { URLCombiner } from '../../url-combiner/url-combiner';
4645
import { FindListOptions } from '../find-list-options.model';
@@ -307,9 +306,9 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
307306
// Ensure all followLinks from the cached object are automatically invalidated when invalidating the cached object
308307
tap((remoteDataObject: RemoteData<T>) => {
309308
if (hasValue(remoteDataObject?.payload?._links)) {
310-
for (const followLinkName of Object.keys(remoteDataObject.payload._links)) {
309+
for (const followLinkName of Object.keys(remoteDataObject.payload._links) as (keyof typeof remoteDataObject.payload._links)[]) {
311310
// only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name
312-
const linkDefinition = this.getLinkDefinition((remoteDataObject.payload as any).constructor, followLinkName);
311+
const linkDefinition: LinkDefinition<T> = getLinkDefinition(remoteDataObject.payload.constructor as GenericConstructor<T>, followLinkName);
313312
if (linkDefinition?.propertyName && hasValue(remoteDataObject.payload[linkDefinition.propertyName]) && followLinkName !== 'self') {
314313
// followLink can be either an individual HALLink or a HALLink[]
315314
const followLinksList: HALLink[] = [].concat(remoteDataObject.payload._links[followLinkName]);
@@ -364,9 +363,9 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
364363
if (hasValue(remoteDataObject?.payload?.page)) {
365364
for (const object of remoteDataObject.payload.page) {
366365
if (hasValue(object?._links)) {
367-
for (const followLinkName of Object.keys(object._links)) {
366+
for (const followLinkName of Object.keys(object._links) as (keyof typeof object._links)[]) {
368367
// only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name
369-
const linkDefinition = this.getLinkDefinition((remoteDataObject.payload as any).constructor, followLinkName);
368+
const linkDefinition: LinkDefinition<PaginatedList<T>> = getLinkDefinition(remoteDataObject.payload.constructor as GenericConstructor<PaginatedList<T>>, followLinkName);
370369
if (linkDefinition?.propertyName && followLinkName !== 'self' && hasValue(object[linkDefinition.propertyName])) {
371370
// followLink can be either an individual HALLink or a HALLink[]
372371
const followLinksList: HALLink[] = [].concat(object._links[followLinkName]);
@@ -522,9 +521,4 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
522521

523522
return done$;
524523
}
525-
526-
getLinkDefinition<D extends HALResource>(source: GenericConstructor<D>, linkName: keyof D['_links']): LinkDefinition<D> {
527-
return getLinkDefinition(source, linkName);
528-
}
529-
530524
}

0 commit comments

Comments
 (0)