Closed tylermercer closed 1 month ago
Hi, can you share your content config or ideally share a minimal repro
Hello @tylermercer. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
Here's a repro: https://github.com/tylermercer/astro-12051-repro. Instructions are in the README.
Thanks. The issue is that you're using reference
inside the loader. While this does work, it's more limited (and we need to document this). It's not able to use the inferred type of the other collection because of how types are generated from schemas in loaders. Loaders don't know anything about other collections, and they're meant to be isolated. This is why it's returning a generic type for the reference. If you move it up into the content config file then it works. I'm going to leave this open because I would like to remove that limitation, but it would still be an anti-pattern to include references inside the loader.
That worked, and makes sense! Thank you for your help.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have two Content Layer collections,
seasons
andepisodes
.episodes
has aseason
property that is defined asreference('seasons')
. But doing things with that reference property is very difficult, due to it's strange type:For example, even though the docs say I can pass this reference property into
getEntry
directly, I'm unable to do so without getting a cryptic type error:Is this the expected type?
What's the expected result?
The reference property is a type that is both usable in itself without a manual typecheck (e.g. a string or a clearly defined object, but not a union of the two), and it can be passed to
getEntry
without a type error.Link to Minimal Reproducible Example
https://github.com/tylermercer/astro-12051-repro
Participation