-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Issues with i18n config typing #10157
Description
Astro Info
Astro v4.4.0
Node v18.18.0
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
Any (n/a)
Describe the Bug
Using this issue to report two related issues with the types for the i18n config.
-
The types for
i18n.routingare inaccurately strict. For example, the following is valid configuration and shown in the Astro docs:import { defineConfig } from 'astro/config'; export default defineConfig({ i18n: { defaultLocale: 'en', locales: ['en', 'fr'], routing: { prefixDefaultLocale: true, }, }, });
However, the above is considered a type error (you need an
astro.config.tsor a// @ts-checkcomment to see this most likely).strategyandredirectToDefaultLocaleare both typed as required ini18n.routing. -
When setting
i18nconfiguration from an Astro integration via theupdateConfig()method, it seems to expect one of the internal enum values like'pathname-prefix-other-locales'rather than the proper configuration object. I suspect the issue is thatupdateConfig()is typed withAstroConfiginstead ofAstroUserConfig, which I think is inaccurate?
What's the expected result?
-
The types should not require
i18n.routingbe set with all values. -
The
updateConfig()integration method should accept the same shape as when setting the config directly.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-cosd7e?file=astro.config.ts
Participation
- I am willing to submit a pull request for this issue.