-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)needs responseIssue needs response from OPIssue needs response from OP
Description
Astro Info
Astro v3.0.10
Node v18.17.0
System macOS (x64)
Package Manager npm
Output server
Adapter @astrojs/node
Integrations astro-compress
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have a page of one post and want to show all tags from this post: src/pages/posts/[slug].astro
---
export const prerender = true;
import type { CollectionEntry } from "astro:content";
import { getEntry, getEntries } from "astro:content";
import { getCollection } from "astro:content";
interface Props {
post: CollectionEntry<"posts">;
}
const { post } = Astro.props;
export async function getStaticPaths() {
const allPosts = await getCollection("posts");
return allPosts.map((post) => ({
params: { slug: post.slug },
props: { post },
}));
}
const { Content } = await post.render();
// get tags data from current post
const tags = await getEntries(post.data.tags);
...
---
...
I receive an error in VS Code:
No overload matches this call.
Overload 1 of 2, '(entries: { collection: "tags"; slug: "black" | "red" | "white"; }[]): Promise<(({ id: "black.md"; slug: "black"; body: string; collection: "tags"; data: { cover?: { src: string; width: number; height: number; format: "png" | ... 5 more ... | "svg"; } | undefined; title: string; }; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; }))[]>', gave the following error.
Overload 2 of 2, '(entries: { collection: never; id: string | number | symbol; }[]): Promise<never[]>', gave the following error.ts(2769)
Screenshot:
What's the expected result?
I follow official docs: https://docs.astro.build/en/guides/content-collections/#accessing-referenced-data
I expect to have no errors.
Link to Minimal Reproducible Example
https://github.com/teinett/learn-astro-images
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)needs responseIssue needs response from OPIssue needs response from OP