Closed Svish closed 4 years ago
Worked around it as follows, but really shouldn't be necessary working around this. Should just be an exported type from the library.
import imageUrlBuilder from '@sanity/image-url';
type ImageUrlBuilder = ReturnType<typeof imageUrlBuilder>;
Could you see if 0.140.16 fixes the issue?
@rexxars Looking at the diff for that version I assume it will, but checking now (if only my slow connection could hurry up) to be sure. Will close the issue when verified. 👍
Yep, I can use the type in my code now:
import React from 'react';
import { ImageUrlBuilder } from '@sanity/image-url/lib/types/builder';
interface ImageProps extends Omit<React.HTMLProps<HTMLImageElement>, 'src'> {
src: string | ImageUrlBuilder;
}
export default function Image(props: ImageProps) {
if (typeof props.src !== 'string') {
props.src = props.src.url()!;
}
// ...
}
👍
Wanted to accept an
ImageUrlBuilder
as a prop in a component, but the type isn't exported, as far as I can see. 😟Like, I can "see" it via my IDE, but since it's not exported, I can't actually use it as a prop or function parameter type. 😕
Please export the
ImageUrlBuilder
type?