Skip to content

Invalid inferred schema types for custom loaders #15905

@HiDeoo

Description

@HiDeoo

Astro Info

Astro                    v6.0.4
Vite                     v7.3.1
Node                     v24.14.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

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

No response

Describe the Bug

Following the Astro v6 change to inferred schema types, inferred types for a custom loader defining a schema are invalid and are just any.

I did not fully investigate yet, but this may be a regression when legacy.collectionsBackwardsCompat was introduced, maybe specifically this one were CollectionConfig was refactored to a union, and now the first member of the union (ContentCollectionConfig) where loader is never is always being picked up? If that's the case, I guess we may need a conditional type with a condition per member of the current union 🤔

What's the expected result?

Having proper inferred type matching the schema defined in the custom content loader.

Link to Minimal Reproducible Example

https://github.com/HiDeoo/astro-6-cc-loader-schema-types-repro

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions