0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix: fix typescript type error in experience phrases

This commit is contained in:
Charles Zhao 2024-07-19 16:11:37 +08:00
parent 4ac4f8cdb4
commit 9024dd5cc2
No known key found for this signature in database
GPG key ID: 4858774754C92DF2

View file

@ -1,10 +1,17 @@
import type en from './locales/en/index.js';
type FlattenKeys<T, Prefix extends string = ''> = {
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<string, unknown>
? `${Prefix}${string & K}.${FlattenKeys<T[K]>}`
? `${Prefix}${string & K}.${FlattenKeys<T[K], '', D, [0, ...A]>}`
: `${Prefix}${string & K}`;
}[keyof T];
}[keyof T];
export type LocalePhrase = typeof en;