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

[Feature Request] Better locales typing in i18n-util.ts #766

Open
Zer0xxxx opened this issue Jun 1, 2024 · 0 comments
Open

[Feature Request] Better locales typing in i18n-util.ts #766

Zer0xxxx opened this issue Jun 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Zer0xxxx
Copy link

Zer0xxxx commented Jun 1, 2024

Version

5.26.2

Describe the bug

Currently:

export const locales: Locales[] = [
  'en-US',
  'fr'
];

Reproduction

Would be better to codegen:

export const locales = [
  'en-US',
  'fr'
] as const;

Or:

export const locales = [
  'en-US',
  'fr'
] as const satisfies readonly [string, ...string[]];

Demo:
Capture d’écran du 2024-06-01 17-28-33

^ We can see the inlay hint is perfectly typed here.

Could also be codegen as:

export const locales = [
  'en-US',
  'fr'
] as const satisfies readonly Locales[];

(Even if it could be pointless to use Locales here, depending on the reliability of the codegen.)

Logs

No response

Config

No response

Additional information

No response

@Zer0xxxx Zer0xxxx added the bug Something isn't working label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant