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.routing are 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.ts or a // @ts-check comment to see this most likely). strategy and redirectToDefaultLocale are both typed as required in i18n.routing.
-
When setting i18n configuration from an Astro integration via the updateConfig() 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 that updateConfig() is typed with AstroConfig instead of AstroUserConfig, which I think is inaccurate?
What's the expected result?
-
The types should not require i18n.routing be 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
Astro Info
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
i18nconfig.The types for
i18n.routingare inaccurately strict. For example, the following is valid configuration and shown in the Astro docs: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