Skip to content

Content typings support roadmap #1057

@Tahul

Description

@Tahul

As for now, if you want to have proper typings when using queryContent; you should pass an argument to it that extends ParsedContentMeta.

import type { ParsedContent } from '@nuxt/content'

interface MySpecificContentType extends ParsedContent {
	foo: 'bar'
	test: 'test'
}

const { data } = await useAsyncData(
	() => queryContent<MySpecificContentType>({ ...yourQuey })
)

const slug = data.value.slug

const foo = data.value.foo

This is obviously not the final approach we want to provide with @nuxt/content.

The next step for us is to generate types in development based on the actual data from these files.

Until we reach that point, the recommended approach is to use type augmentation, which will be the easiest "change" to replace in your codebase once that type generation feature reaches release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions