-
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/image': patch | ||
--- | ||
|
||
Updated error message for missing `widths` prop to provide an example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrojs/image": patch | ||
--- | ||
|
||
Allow passing `undefined` to TransformOptions, this is a types fix for users with `exactOptionalTypes` enabled in their tsconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line 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 commentThe reason will be displayed to describe this comment to others. Learn more. x?: string and |
||
/** | ||
* The compression quality used during optimization. | ||
* | ||
* @default undefined Allows the image service to determine defaults. | ||
*/ | ||
quality?: number; | ||
quality?: number | undefined; | ||
/** | ||
* The desired width of the output image. Combine with `height` to crop the image | ||
* to an exact size, or `aspectRatio` to automatically calculate and crop the height. | ||
*/ | ||
width?: number; | ||
width?: number | undefined; | ||
/** | ||
* The desired height of the output image. Combine with `height` to crop the image | ||
* to an exact size, or `aspectRatio` to automatically calculate and crop the width. | ||
*/ | ||
height?: number; | ||
height?: number | undefined; | ||
/** | ||
* The desired aspect ratio of the output image. Combine with either `width` or `height` | ||
* to automatically calculate and crop the other dimension. | ||
* | ||
* @example 1.777 - numbers can be used for computed ratios, useful for doing `{width/height}` | ||
* @example "16:9" - strings can be used in the format of `{ratioWidth}:{ratioHeight}`. | ||
*/ | ||
aspectRatio?: number | `${number}:${number}`; | ||
aspectRatio?: number | `${number}:${number}` | undefined; | ||
/** | ||
* The background color to use when converting from a transparent image format to a | ||
* non-transparent format. This is useful for converting PNGs to JPEGs. | ||
|
@@ -131,19 +131,19 @@ export interface TransformOptions { | |
* @example "#ffffff" - a hex color | ||
* @example "rgb(255, 255, 255)" - an rgb color | ||
*/ | ||
background?: ColorDefinition; | ||
background?: ColorDefinition | undefined; | ||
/** | ||
* How the image should be resized to fit both `height` and `width`. | ||
* | ||
* @default 'cover' | ||
*/ | ||
fit?: CropFit; | ||
fit?: CropFit | undefined; | ||
/** | ||
* Position of the crop when fit is `cover` or `contain`. | ||
* | ||
* @default 'centre' | ||
*/ | ||
position?: CropPosition; | ||
position?: CropPosition | undefined; | ||
} | ||
|
||
export interface HostedImageService<T extends TransformOptions = TransformOptions> { | ||
|
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.
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"
thenwidths="100vw"
until I get towidths=[100]
and thenwidths={[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.