diff --git a/packages/phrases-experience/src/types.ts b/packages/phrases-experience/src/types.ts index 3e24bfff0..de7e4a903 100644 --- a/packages/phrases-experience/src/types.ts +++ b/packages/phrases-experience/src/types.ts @@ -1,10 +1,17 @@ import type en from './locales/en/index.js'; -type FlattenKeys = { - [K in keyof T]: T[K] extends Record - ? `${Prefix}${string & K}.${FlattenKeys}` - : `${Prefix}${string & K}`; -}[keyof T]; +type FlattenKeys< + T, + Prefix extends string = '', + D extends number = 11, // Depth limit is actually 10, since the initial value of A is [0] + A extends unknown[] = [0], +> = A['length'] extends D + ? never + : { + [K in keyof T]: T[K] extends Record + ? `${Prefix}${string & K}.${FlattenKeys}` + : `${Prefix}${string & K}`; + }[keyof T]; export type LocalePhrase = typeof en;