-
-
Notifications
You must be signed in to change notification settings - Fork 728
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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.fooThis 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.
ManasMadrecha, mblackritter, leopoldkristjansson, AlansCodeLog, helltraitor and 4 moremblackritter and tsavo-at-piecesPatrickMcGrath29, Patrick-Remy, sadeghbarati, florian-lefebvre, tesla3327 and 12 moremblackritter, marcelxpfeifer and ThimoDEVmblackritter, lucperkins, marcelxpfeifer, just-maik and paulmeleromblackritter, lucperkins and carlossolmedo
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request