NotCMS provides full type inference for fetched items:
Copy
// Infer single page typetype BlogPost = typeof nc.query.blog.$inferPage;// Use in your functionsfunction processBlogPost(post: BlogPost) { // Full type safety and IDE autocomplete console.log(post.title); console.log(post.published); console.log(post.author);}
async function getPostWithAuthor(postId: string) { // Get the post const [post, postError] = await nc.query.blog.get(postId); if (postError) throw postError; // Get the author const [author, authorError] = await nc.query.authors.get(post.properties.authors[0]); if (authorError) throw authorError; return { ...post, author };}