CodeStitchOfficial / Intermediate-Astro-v4-Decap-CMS

This intermediate kit includes a pre-configured setup for Astro v4, including a blog powered by DecapCMS and Astro's Content Collections. Also features Dark Mode, ViewTransitions and Components, complete with CodeStitch UI.
https://intermediate-astro-kit-decap-cms.netlify.app/
19 stars 4 forks source link

Module '"astro:content"' has no exported member 'defineCollection'.ts (2305) and Module '"astro:content"' has no exported member 'z'.ts(2305) #3

Closed NHLopez closed 1 month ago

NHLopez commented 1 month ago

I'm having a small error (Intermediate-Astro-v4-Decap-CMS) and I can't figure a way to resolve it with out just putting // @ts-ignore on it. In my content/blog/config.ts file, In my imports "import { defineCollection, z} from "astro:content";" I am getting 2 errors. 1) Module '"astro:content"' has no exported member 'defineCollection'.ts (2305) and 2) Module '"astro:content"' has no exported member 'z'. When I go to the .astro folder where types.d.ts is located I see modules of "astro:content"

import { defineCollection, z} from "astro:content";  // This line right here

// Every collection must reflect Decap's config.yml collection schema
// In order to be able to optimize images with Astro built-in compoments, like <Image />, we first must use this image helper 
// Doc: https://docs.astro.build/en/guides/images/#images-in-content-collections

const blogsCollection = defineCollection({ 
    type: "content", 
    schema: ({ image }) =>
        z.object({
            `title: z.string(),
            description: z.string(),
            author: z.string(),
            date: z.date(),
            tags: z.array(z.string()),
            image: image(),
            imageAlt: z.string(),
        }),
});

export const collections = {
    blog: blogsCollection,
};

When first opening the kit on the dev server, the .astro/ folder is created with a types.d.ts which is supposedly where the types for the 2 modules { defineCollection, z} are generated. However, TypeScript is still upset with me.

I’ve tried resetting the TS server, reinstalling prettier, using npx astro sync, and have read even through the astro docs to find a solution https://docs.astro.build/en/guides/content-collections/ . I appreciate any help on this.

BuckyBuck135 commented 1 month ago

Hi @NHLopez, Thanks for your feedback. It should now be fixed with this commit

I'll close the issue, but feel free to reopen it if necessary.