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

Typescript: locale type Improvement #65

Open
alex-way opened this issue May 4, 2022 · 1 comment
Open

Typescript: locale type Improvement #65

alex-way opened this issue May 4, 2022 · 1 comment
Labels
base Issue related to base functionality enhancement New feature or request help wanted Extra attention is needed typescript Issue related to type definitions
Milestone

Comments

@alex-way
Copy link

alex-way commented May 4, 2022

export const { t, locale, locales, loading, loadTranslations } = new i18n(config);

locale exposes a svelte store which is used to get/set the locale throughout the app. However, the type on it is weak (string).

It should be possible to infer the locale Type more strongly using the configuration provided?

@jarda-svoboda jarda-svoboda added enhancement New feature or request base Issue related to base functionality typescript Issue related to type definitions labels May 4, 2022
@jarda-svoboda jarda-svoboda added this to the 2.x milestone May 4, 2022
@jarda-svoboda
Copy link
Member

@alex-way this one seems to be a bit challenging as long as we need to allow user to use any string as a locale in config...

The problem is that we cannot (AFAIK) infer type directly from string[] so we would need to use generic type instead.. so it would work like this

@jarda-svoboda jarda-svoboda added the help wanted Extra attention is needed label May 22, 2022
@jarda-svoboda jarda-svoboda modified the milestones: 2.x, 2.2.3 May 26, 2022
@jarda-svoboda jarda-svoboda modified the milestones: 2.3.0, 2.x Jul 4, 2023
@jarda-svoboda jarda-svoboda modified the milestones: 2.x, 3.x Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base Issue related to base functionality enhancement New feature or request help wanted Extra attention is needed typescript Issue related to type definitions
Projects
None yet
Development

No branches or pull requests

2 participants