Skip to content

Conversation

delucis
Copy link
Member

@delucis delucis commented Apr 25, 2024

Description

  • Closes type errors using extended i18n schema #1787
  • Fixes type inference for labels when a user provides additional translation strings by extending Starlight’s i18n schema
  • Previously these were statically typed based on our default schema shape. Now these should infer from the content collection type if configured.

Testing

To test this, I followed these manual steps:

  1. Extended the i18n schema in docs/src/content/config.ts with an extra field:

    schema: i18nSchema({ extend: z.object({ test: z.string() }) }),
  2. I added a test file at docs/src/content/i18n/lang.yml to make Astro detect the collection, and added some content:

    test: test
  3. I created a test component using our overrides prop type to see if it would pick up the extended field in labels:

    ---
    import type { Props } from '@astrojs/starlight/props';
    
    Astro.props.labels.test
    //                 ^ string
    ---

Copy link

changeset-bot bot commented Apr 25, 2024

🦋 Changeset detected

Latest commit: dc90395

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

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

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

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Apr 30, 2024 9:48am
1 Ignored Deployment
Name Status Preview Updated (UTC)
starlight-i18n ⬜️ Ignored (Inspect) Apr 30, 2024 9:48am

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Apr 25, 2024
@delucis delucis added the 🌟 patch Change that triggers a patch release label Apr 25, 2024
@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Apr 25, 2024

size-limit report 📦

Path Size
/index.html 6.1 KB (0%)
/_astro/*.js 21.57 KB (0%)
/_astro/*.css 13.45 KB (0%)

Copy link
Member

@HiDeoo HiDeoo left a comment

Choose a reason for hiding this comment

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

Amazing!

Tested this against #1777 and it does not have the same issue (no idea about the criteria before a type is no longer serializable). I also tested it as-is and with the fix from #1777 and it works perfectly in both cases. 🚀

@delucis delucis merged commit d05d693 into main Apr 30, 2024
@delucis delucis deleted the chris/fix-i18n-extension-types branch April 30, 2024 09:49
@astrobot-houston astrobot-houston mentioned this pull request Apr 30, 2024
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Apr 30, 2024
* main: (63 commits)
  Add translation for copy button (withastro#1788)
  Update astro-expressive-code (withastro#1720)
  Fix type inference for extended i18n schemas (withastro#1786)
  Fix TypeScript schema error when using project references (withastro#1777)
  Update fa.json (withastro#1793)
  i18n(fr): update `resources/community-content.mdx` (withastro#1795)
  [ci] format
  i18n(ko-KR): update `community-content.mdx` (withastro#1794)
  [ci] format
  Adds Starlight in Next.js project video (withastro#1789)
  [ci] format
  i18n(ru): update translations (withastro#1783)
  i18n(id): Update getting-started.mdx (withastro#1778)
  Upgrade Lunaria and add Action (withastro#1768)
  [ci] format
  i18n(es): update `sidebar` (withastro#1767)
  i18n(pt-br): Update `getting-started.mdx` (withastro#1776)
  i18n(es): update `configuration` (withastro#1766)
  [ci] format
  Add TrueCharts to showcases (withastro#1773)
  ...
Yoxnear pushed a commit to Yoxnear/starlight-custom that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 🌟 patch Change that triggers a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type errors using extended i18n schema
3 participants