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

[prototype] typed i18n params #55

Closed
wants to merge 1 commit into from
Closed

Conversation

itwillwork
Copy link
Contributor

No description provided.

@itwillwork itwillwork requested a review from dgaponov as a code owner August 12, 2024 13:27
type KeyParam<Path extends string> =
Path extends `${infer L}{{${infer K}}}${infer R}`
? K | KeyParam<L> | KeyParam<R>
: never;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавляется такая небольшая утилитка для поиска параметров в строке

bind(thisArg: any): <K extends keyof T, G extends keyof T[K], S extends string>(keysetName: K, key: G | NoEnumLikeStringLiteral<S>, params?: Params<T[K][G]>) => string;
bind<K extends keyof T>(thisArg: any, keysetName: K): <G extends keyof T[K], S extends string>(key: G | NoEnumLikeStringLiteral<S>, params?: Params<T[K][G]>) => string;
bind<K extends keyof T, G extends keyof T[K], S extends string>(thisArg: any, keysetName: K, key: G | NoEnumLikeStringLiteral<S>): (params?: Params<T[K][G]>) => string;
bind<K extends keyof T, G extends keyof T[K], S extends string>(thisArg: any, keysetName: K, key: G | NoEnumLikeStringLiteral<S>, params?: Params<T[K][G]>): () => string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут меняется только возвращаемое значение оно всегда string

: KeyParam<K['zero']> | KeyParam<K['one']> | KeyParam<K['two']> | KeyParam<K['few']> | KeyParam<K['many']> | KeyParam<K['other']>
, any
>;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и типизируются параметры

@itwillwork itwillwork closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant