Skip to content

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

@Zer0xxxx

Description

@Zer0xxxx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions