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

fix(i18n): make i18n.routing fields optional #10165

Merged
merged 3 commits into from
Feb 20, 2024
Merged

fix(i18n): make i18n.routing fields optional #10165

merged 3 commits into from
Feb 20, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Feb 20, 2024

Changes

Addresses the typing issue of #10157

The properties inside i18n.routing were incorrectly typed. Now they are optional.

The type of domains was placed in the wrong part of the config... ooops! I fixed that too

Testing

It should compile and current tests should pass

Docs

N/A

Copy link

changeset-bot bot commented Feb 20, 2024

🦋 Changeset detected

Latest commit: d8154be

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 20, 2024
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me!

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this tested? .default() marks a field as optional already so this wouldn't change anything I don't think? I think the issue I noticed with types might come from the manual types file not the schema?

@ematipico
Copy link
Member Author

ematipico commented Feb 20, 2024

How was this tested? .default() marks a field as optional already so this wouldn't change anything I don't think? I think the issue I noticed with types might come from the manual types file not the schema?

Turns out, it does not, unless that's a bug in zod. The current changes aren't woking. Doing prefixDefaultLocale: z.boolean().optional().default(false), emits a prefixDefaultLocale: boolean, while prefixDefaultLocale: z.boolean().optional() emits a prefixDefaultLocale?: boolean | undefined.

The thing is, we need a default value.

@github-actions github-actions bot added the pr: docs A PR that includes documentation for review label Feb 20, 2024
@ematipico
Copy link
Member Author

Totally forgot that astro.config doesn't use the schema, but it uses astro.d.ts. I changed the types there and it works like a charm now. I used a pet project to test it
Screenshot 2024-02-20 at 08 59 48

cc @delucis @Princesseuh

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @types/astro.ts changes look good! (Although there’s an indentation change I guess the auto-formatter will revert?)

Left a suggestion to remove the unnecessary .optional()s in the schema.

packages/astro/src/core/config/schema.ts Outdated Show resolved Hide resolved
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this so quickly @ematipico!

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always forget how the types for the config interact too, oops.

@ematipico ematipico merged commit d50dddb into main Feb 20, 2024
14 checks passed
@ematipico ematipico deleted the fix/i18n-typing branch February 20, 2024 10:17
@astrobot-houston astrobot-houston mentioned this pull request Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants