fix (core): allow falsy values in astro config integrations arrays #4427
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
TL;DR: this updates the astro config type to allow falsy values in the
integrations
array, which the docs indicate should be possible. Related: withastro/docs#1334The docs state:
However, Typescript will generate the following error if you try to do this:
In this particular change, I've chosen a nullish interpretation of "falsy" allowing
false
,null
, andundefined
. I'm happy to update to a more conservativefalse
only solution, which might read more cleanly.Based on the schema in https://github.com/withastro/astro/blob/main/packages/astro/src/core/config.ts#L139, I believe this is a safe change, as the looser type will still conform to the validation format due to the
filter(Boolean)
preprocessing.I'm in a bit over my head with the contribution formula here, so holler at me if I've done something wrong or there's a better way to handle this.
Testing
Tests are not included because I couldn't get them to fully run locally with a fresh install prior to making this change. I'm hoping the PR checks will run the appropriate checks, at which point I'll update.
Docs
There are no changes to the docs, as this change brings the codebase inline with what the docs already state.