Skip to content

Conversation

@florian-lefebvre
Copy link
Member

Changes

  • Now generates types for the Font component family prop
  • Fixes a bug where the map passed to the virtual module was not using family.as if provided

Testing

Updated + manual

Docs

N/A

@florian-lefebvre florian-lefebvre self-assigned this Mar 19, 2025
@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2025

⚠️ No Changeset found

Latest commit: e8a9804

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 19, 2025
@@ -0,0 +1,4 @@
declare module 'astro:assets' {
/** Run `astro dev` or `astro sync` to generate high fidelity types */
export type FontFamily = string;
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a better way? This should be considered an internal type

Copy link
Member

Choose a reason for hiding this comment

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

Can you provide some context? I'm not sure I understand what you're trying to achieve and what's the limitation of the current solution

Copy link
Member Author

@florian-lefebvre florian-lefebvre Mar 19, 2025

Choose a reason for hiding this comment

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

Sorry it was clear for me of course 😆

So what I want is:

  • By default, the family prop of the Font component must be typed as string
  • If some fonts are registered, make this prop strictly typed using codegen

This currently works but I'm using astro:assets to pass the type. I think this makes FontFamily part of the public API but it should be considered internal IMO.

So what can we do about it? I guess an easy way would be to add @internal

Copy link
Member

Choose a reason for hiding this comment

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

We could use @internal. How would users use the generated type instead?

@florian-lefebvre florian-lefebvre merged commit 93ffd30 into feat/fonts Mar 21, 2025
4 checks passed
@florian-lefebvre florian-lefebvre deleted the feat/fonts-component-family-typegen branch March 21, 2025 09:38
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants