-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fonts: fix typing for disabled fallbacks (empty array) #13681
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
Fonts: fix typing for disabled fallbacks (empty array) #13681
Conversation
🦋 Changeset detectedLatest commit: 00926a2 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 |
CodSpeed Performance ReportMerging #13681 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the nature of this fix. I recall that having an empty array for fallback must be an error. Do we have a configuration test for this case? Can you check @altano, and make sure that fallback: [] throws an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you also add a test case here? https://github.com/withastro/astro/blob/main/packages/astro/test/units/config/config-validate.test.js#L391
|
@ematipico empty fallbacks should not throw an error, this is a proper bug |
7951c02 to
362a7a2
Compare
Done, PR updated. But let me know if you had something more in mind, as I just added a basic " assert.doesNotThrow(() =>
validateConfig({
experimental: {
fonts: [
{
provider: fontProviders.google(),
name: 'Roboto',
fallbacks: [],
cssVariable: '--font-roboto',
},
],
},
}),
); |
Documentation says: > To disable fallback fonts completely, configure an empty array: > > fallbacks: [] But I get a Typescript error if I do that. This is a simple typing issue, not a behavioral one, so in this PR I am: - fixing the type so an empty array is allowed, to match the doc - adding a type test that fails before this change and succeeds after: > test/types/define-config.ts:150:8 - error TS2322: Type '[]' is not assignable to type '[string, ...string[]]'. > Source has 0 element(s) but target requires 1. > > 150 fallbacks: [], > ~~~~~~~~~ Partially addresses withastro#13659
362a7a2 to
042ffc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Co-authored-by: Florian Lefebvre <[email protected]>
Changes
Regarding experimental fonts, the documentation says:
But I get a Typescript error if I do that. This is a simple typing issue, not a behavioral one, so in this PR I am:
Closes #13659
Testing
Added a type test that fails before this change and succeeds after:
BEFORE:
AFTER:
Docs
Bringing types in line with docs, no doc updates needed