Next.js Discord

Discord Forum

Hi all, does anyone have any ideas on how I can solve this typescript error?

Answered
Jacquit posted this in #help-forum
Open in Discord
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];
};
}
Answered by Rufous-winged Sparrow
interface Image {
src: string;
alt: string;
}

interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
View full answer

3 Replies

Rufous-winged Sparrow
interface Image {
src: string;
alt: string;
}

interface Props {
data: {
title: string;
subtitle: string;
paragraphs: Array<string>;
images: Image[];
};
}
Answer
Rufous-winged Sparrow
This should work
Thank you!