Hi all, does anyone have any ideas on how I can solve this typescript error?
Answered
Jacquit posted this in #help-forum
JacquitOP
Type '{ src: string; alt: string; }[]' is not assignable to type '[Image, Image, Image, Image]' and also specifies the number of the images to be.
These are my interfaces:
interface Image {
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: [Image, Image, Image, Image];
};
}
These are my interfaces:
interface Image {
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: [Image, Image, Image, Image];
};
}
Answered by Rufous-winged Sparrow
interface Image {
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
3 Replies
Rufous-winged Sparrow
interface Image {
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
src: string;
alt: string;
}
interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
Answer
Rufous-winged Sparrow
This should work
JacquitOP
Thank you!