-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Issues with i18n config typing #10157
Comments
Moved this back to "needs triage" after looking at the code. I'm not completely certain that this is a bug or not. The code all uses |
Do we have other parts of the config that do radical transformations like |
Yeah, normally we don't do dramatic changes. State derived from config usually goes on the AstroSettings object. @ematipico would it be possible to move this derived state there and to keep the config structure intact? |
I was under the impression that user config and integrations config is the same. If not, they should. The transformation that I applied was supposed to be internal to Astro. What's the best course of action? |
I’m not super familiar with how the i18n code uses the config, but Matthew suggested above that AstroSettings could get the transformed form. In other words this mapping of the config to the string form would happen there? astro/packages/astro/src/core/config/schema.ts Lines 366 to 396 in 9b78c99
Would i18n code be able to read that off |
I mean, everything is possible, but I believe that not doing transformations as we want is a huge constraint, and this issue shows it clearly. I'll have to think about it |
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
i18n
config.The types for
i18n.routing
are 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.ts
or a// @ts-check
comment to see this most likely).strategy
andredirectToDefaultLocale
are both typed as required ini18n.routing
.When setting
i18n
configuration 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 withAstroConfig
instead ofAstroUserConfig
, 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
The text was updated successfully, but these errors were encountered: