Whenever I try to use fallback: 'blocking',
in my Next.js page, TypeScript throws an error. I am using the latest 12.2.0 version of Next.js. What could be causing this issue?
Type '() => Promise<{ paths: any; fallback: string; }>' is not assignable to type 'GetStaticPaths<ParsedUrlQuery>'.
Type 'Promise<{ paths: any; fallback: string; }>' is not assignable to type 'GetStaticPathsResult<ParsedUrlQuery> | Promise<GetStaticPathsResult<ParsedUrlQuery>>'.
Type 'Promise<{ paths: any; fallback: string; }>' is not assignable to type 'Promise<GetStaticPathsResult<ParsedUrlQuery>>'.
Type '{ paths: any; fallback: string; }' is not assignable to type 'GetStaticPathsResult<ParsedUrlQuery>'.
Types of property 'fallback' are incompatible.
Type 'string' is not assignable to type 'boolean | "blocking"'.
Here's the code snippet:
export const getStaticPaths: GetStaticPaths = async () => {
// ...
const paths = res.data.map((organizationAndPostId: string) => ({
params: {
organizationShortId: organizationAndPostId[0],
postId: organizationAndPostId[1],
tempUserShortId: organizationAndPostId[2],
imgId: organizationAndPostId[3],
},
}))
let ret = {
paths,
fallback: 'blocking',
}
return ret
}
I suspect the issue could be related to the quotes used in the code. Despite manually changing it to '
, VSCode keeps converting it automatically.