Skip to content

Strapi generated types support #489

@MLoth

Description

@MLoth

After some testing I couldn't figure out how to use the Strapi generated types (types/generated/**) with this module.

I read somewhere that here all the 'attributes' are omitted. Is there a config to keep using the same types just like Strapi generates them?
Or is there a workaround to generate Strapi types like they are provided in this module (I prefer this option 🙂).

import type { ApiHomeHome } from '@mloth/strapi' // A package in my monorepo

const { data } = await useAsyncData('home', () =>
  findOne<ApiHomeHome>('home', '', {
    locale: locale.value,
    populate: [
      'hero', // Gives type error but 'data' is correct
      'attributes.hero', // No type error, but not in 'data'
    ],
  }),
)

So in short: how to leverage the autogenerated types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions