withastro/astro

Content's reference type is not aligned with runtime value

Takeno opened this issue · 2 comments

Astro Info

Astro                    v5.0.0-beta.7
Node                     v18.18.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When defining collection reference, the type of referenced content is {collection: string; slug: string} but it's runtime value is {collection: string; id: string}

Typescript:

(property) related?: {
    collection: "blog";
    slug: "first-post" | "second-post" | "using-mdx";
} | undefined

Runtime:

{ id: 'second-post', collection: 'blog' }

What's the expected result?

The type should be aligned to runtime value

Link to Minimal Reproducible Example

Takeno/astro-content-reference-type-bug@40f5ffd

Participation

  • I am willing to submit a pull request for this issue.

@Takeno do you experience the same issue in v4? FYI we plan to eventually sunset content collections in favour of content layer. This is going to be probably in v6 (nothing is sure yet), but in v5 we encourage people to use content layer instead.

@ematipico No. I tried with latest v4 and it has slug property at runtime