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:
parent
4ac4f8cdb4
commit
9024dd5cc2
1 changed files with 12 additions and 5 deletions
|
@ -1,10 +1,17 @@
|
||||||
import type en from './locales/en/index.js';
|
import type en from './locales/en/index.js';
|
||||||
|
|
||||||
type FlattenKeys<T, Prefix extends string = ''> = {
|
type FlattenKeys<
|
||||||
[K in keyof T]: T[K] extends Record<string, unknown>
|
T,
|
||||||
? `${Prefix}${string & K}.${FlattenKeys<T[K]>}`
|
Prefix extends string = '',
|
||||||
: `${Prefix}${string & K}`;
|
D extends number = 11, // Depth limit is actually 10, since the initial value of A is [0]
|
||||||
}[keyof T];
|
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], '', D, [0, ...A]>}`
|
||||||
|
: `${Prefix}${string & K}`;
|
||||||
|
}[keyof T];
|
||||||
|
|
||||||
export type LocalePhrase = typeof en;
|
export type LocalePhrase = typeof en;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue