#Routing - Pagination TypeScript Error

2 messages · Page 1 of 1 (latest)

merry palm
#

Hello everyone,

I'm currently working on implementing pagination for a blog using Astro, and I've encountered a TypeScript error that I'm struggling to resolve. When attempting to utilize pagination to split a collection into multiple pages, I'm getting the following error: "Property 'data' does not exist on type 'never'.ts(2339)". I'm not sure how to fix this issue.

I uploaded the relevant code snippets

covert jetty
#

If you hover over allPosts does it show you the correct type?
If you hover over sortedPosts does it show you the correct type?
If you pass allPosts into paginate(), instead of sortedPosts, does it work?
If so, you can try casting it, like: const sortedPosts: CollectionEntry<"posts">[] = ...