-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
@astrojs/image
: Allow passing undefined
to transform options
#6008
Conversation
This fixes #6001, allowing undefined passed as a variable in addition to not passing the property at all
🦋 Changeset detectedLatest commit: 835b66f 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 |
undefined
to transform options@astrojs/image
: Allow passing undefined
to transform options
@@ -51,7 +51,7 @@ export async function getPicture(params: GetPictureParams): Promise<GetPictureRe | |||
} | |||
|
|||
if (!widths || !Array.isArray(widths)) { | |||
throw new Error('[@astrojs/image] at least one `width` is required'); | |||
throw new Error('[@astrojs/image] at least one `width` is required. ex: `widths={[100]}`'); |
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.
Maybe I should put this in a separate PR 😓
I've been confused every time I've gotten this error, trying to pass width="100vw"
then widths="100vw"
until I get to widths=[100]
and then widths={[100]}
😅
weird that astro devtools doesn't seem to pick it up as 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.
Yeah, this message isn't great. I'm fine with this being in the same PR, it's just a very simple string change.
@@ -98,31 +98,31 @@ export interface TransformOptions { | |||
* | |||
* @default undefined The original image format will be used. | |||
*/ | |||
format?: OutputFormat; | |||
format?: OutputFormat | undefined; |
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.
x?: string and x: string | undefined
are different when exactOptionalProperties
is true in tsconfig
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.
Looks good to me, thank you!
Changes
There may be more places in the integration where this is needed, idk.
Testing
Docs
I don't think the docs need an update? This is just a change for users w/
astro/tsconfigs/strictest
enabled