Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate the translations type checking #1651

Open
forgetso opened this issue Jan 29, 2025 · 0 comments
Open

Reinstate the translations type checking #1651

forgetso opened this issue Jan 29, 2025 · 0 comments
Labels
dev Product development size-m

Comments

@forgetso
Copy link
Member

This was removed as it was too complex

export type TFunctionParams = Parameters<TFunction>

// https://medium.com/xgeeks/typescript-utility-keyof-nested-object-fa3e457ef2b2
// slightly modified since we only need string keys, number is there so IDE/Typescript doesn't complain
type NestedKeyOf<ObjectType extends object> = {
    [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
        ? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
        : `${Key}`
}[keyof ObjectType & (string | number)]

but it does correctly type translation strings.

// https://medium.com/xgeeks/typescript-utility-keyof-nested-object-fa3e457ef2b2
// slightly modified since we only need string keys, number is there so IDE/Typescript doesn't complain
type NestedKeyOf<ObjectType extends object> = {
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
: `${Key}`
}[keyof ObjectType & (string | number)]

@forgetso forgetso added dev Product development size-m labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Product development size-m
Projects
None yet
Development

No branches or pull requests

1 participant