diff --git a/packages/core/src/common/types/entity-relation-paths.ts b/packages/core/src/common/types/entity-relation-paths.ts index 268e8a1225..133d4beb40 100644 --- a/packages/core/src/common/types/entity-relation-paths.ts +++ b/packages/core/src/common/types/entity-relation-paths.ts @@ -1,5 +1,7 @@ import { VendureEntity } from '../../entity/base/base.entity'; +import { Translation } from './locale-types'; + /** * @description * This type allows type-safe access to entity relations using strings with dot notation. @@ -27,11 +29,11 @@ export type EntityRelationPaths = | TripleDotPath; export type EntityRelationKeys = { - [K in Extract]: Required[K] extends VendureEntity | null - ? K - : Required[K] extends VendureEntity[] + [K in Extract]: Required[K] extends VendureEntity | Translation | null ? K - : never; + : Required[K] extends VendureEntity[] | Array> + ? K + : never; }[Extract]; export type EntityRelations = { @@ -50,8 +52,8 @@ export type PathsToStringProps2 = T extends string [K in EntityRelationKeys]: T[K] extends VendureEntity[] ? [K, PathsToStringProps1] : T[K] extends VendureEntity | undefined - ? [K, PathsToStringProps1>] - : never; + ? [K, PathsToStringProps1>] + : never; }[Extract, string>]; export type TripleDotPath = `${string}.${string}.${string}`; @@ -60,10 +62,10 @@ export type TripleDotPath = `${string}.${string}.${string}`; export type Join, D extends string> = T extends [] ? never : T extends [infer F] - ? F - : // eslint-disable-next-line no-shadow,@typescript-eslint/no-shadow - T extends [infer F, ...infer R] - ? F extends string - ? `${F}${D}${Join, D>}` - : never - : string; + ? F + : // eslint-disable-next-line no-shadow,@typescript-eslint/no-shadow + T extends [infer F, ...infer R] + ? F extends string + ? `${F}${D}${Join, D>}` + : never + : string;