From 638e87aeb97a04c0b8fbb160bd65a1d26028335e Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 12 Apr 2024 13:58:56 -1000 Subject: [PATCH] fix: type error in `mapSliceZone` (#339) --- src/helpers/mapSliceZone.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/helpers/mapSliceZone.ts b/src/helpers/mapSliceZone.ts index 909c56c0..9cac22a8 100644 --- a/src/helpers/mapSliceZone.ts +++ b/src/helpers/mapSliceZone.ts @@ -19,7 +19,7 @@ type AnyFunction = (...args: any[]) => any; * * @typeParam Slice - The Slice from which the type will be extracted. */ -type ExtractSliceType = TSlice extends Slice +type ExtractSliceType = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] @@ -175,7 +175,7 @@ type MapSliceLike< // eslint-disable-next-line @typescript-eslint/no-explicit-any TSliceLike extends SliceLike, TSliceMappers extends SliceMappers< - SliceLike>, + TSliceLike, // eslint-disable-next-line @typescript-eslint/no-explicit-any any >, @@ -232,13 +232,7 @@ export function mapSliceZone< sliceZone: SliceZoneLike, mappers: TSliceMappers, context?: TContext, -): Promise< - MapSliceLike< - TSliceLike, - // @ts-expect-error - I don't know how to fix this type - TSliceMappers - >[] -> { +): Promise[]> { return Promise.all( sliceZone.map(async (slice, index, slices) => { const isRestSliceType = "slice_type" in slice;