Open
Description
Hello 😄 first of all, amazing package, thank you for releasing and maintaining it.
I've noticed that when I try and define the return type of the getStaticProps()
function (Next.js), if I use an interface that defines the contentType
I get a typescript error on the contentType.sys.id
property, complaining that type string is incompatible with the string literal (in my example, "city"
).
Here's the code snippet:
interface Props {
cities: ICity[];
}
export const getStaticProps: GetStaticProps<Props> = async context => {
const client = createClient({
space: process.env.CONTENTFUL_SPACE,
accessToken: process.env.CONTENTFUL_TOKEN
});
const cities = await client.getEntries<ICityFields>({
content_type: 'city'
});
return {
props: {
cities: cities.items
}
}
}
And a snapshot of the error:
For now, I'm asserting the type in the return statement to make the error go away - which isn't much of an inconvenience tbh. Is this the correct solution?
return {
props: {
cities: cities.items as ICity[]
}
}
Metadata
Metadata
Assignees
Labels
No labels