mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(assets): fix getImage
options type (#12349)
This commit is contained in:
parent
20e5a843c8
commit
1fc83d3ba8
3 changed files with 13 additions and 3 deletions
5
.changeset/long-monkeys-exercise.md
Normal file
5
.changeset/long-monkeys-exercise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes the `getImage` options type so it properly extends `ImageTransform`
|
|
@ -1,4 +1,4 @@
|
|||
import type { WithRequired } from '../type-utils.js';
|
||||
import type { OmitPreservingIndexSignature, Simplify, WithRequired } from '../type-utils.js';
|
||||
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
|
||||
import type { ImageService } from './services/service.js';
|
||||
|
||||
|
@ -66,10 +66,10 @@ export type SrcSetValue = UnresolvedSrcSetValue & {
|
|||
/**
|
||||
* A yet to be resolved image transform. Used by `getImage`
|
||||
*/
|
||||
export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & {
|
||||
export type UnresolvedImageTransform = Simplify<OmitPreservingIndexSignature<ImageTransform, 'src'> & {
|
||||
src: ImageMetadata | string | Promise<{ default: ImageMetadata }>;
|
||||
inferSize?: boolean;
|
||||
} & {
|
||||
}> & {
|
||||
[isESMImport]?: never;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,11 @@ export type OmitIndexSignature<ObjectType> = {
|
|||
: KeyType]: ObjectType[KeyType];
|
||||
};
|
||||
|
||||
// This is an alternative `Omit<T, K>` implementation that _doesn't_ remove the index signature of an object.
|
||||
export type OmitPreservingIndexSignature<T, K extends PropertyKey> = {
|
||||
[P in keyof T as Exclude<P, K>]: T[P]
|
||||
};
|
||||
|
||||
// Transform a string into its kebab case equivalent (camelCase -> kebab-case). Useful for CSS-in-JS to CSS.
|
||||
export type Kebab<T extends string, A extends string = ''> = T extends `${infer F}${infer R}`
|
||||
? Kebab<R, `${A}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`>
|
||||
|
|
Loading…
Reference in a new issue