Skip to content
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

Merged
merged 4 commits into from
Jan 27, 2023

Conversation

jasikpark
Copy link
Contributor

@jasikpark jasikpark commented Jan 27, 2023

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

This fixes #6001, allowing undefined passed as a variable in addition to not passing the property at all
@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2023

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jan 27, 2023
@jasikpark jasikpark changed the title Allow passing undefined to transform options @astrojs/image: Allow passing undefined to transform options Jan 27, 2023
@@ -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]}`');
Copy link
Contributor Author

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

Copy link
Member

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;
Copy link
Contributor Author

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

Copy link
Member

@Princesseuh Princesseuh left a 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!

@Princesseuh Princesseuh merged commit 9c298aa into main Jan 27, 2023
@Princesseuh Princesseuh deleted the fix-some-astro-image-types branch January 27, 2023 17:05
This was referenced Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image integration types are wrong for an astro project w/ the strictest settings enabled.
2 participants