Generating TypeScript Types from Contentful

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024
  • НаукаНаука

Комментарии • 4

  • @josuesuarezcampos6714
    @josuesuarezcampos6714 Год назад +1

    This is awesome. I was tired of trying to figure it out how to write all the types properly. Now we can do it automatically!

  • @brianstanback360
    @brianstanback360 5 месяцев назад

    Thanks very helpful, I had to add a --v10 argument when generating the types to make it play nicely with v10 of the contentful SDK

  • @DlSechi
    @DlSechi Год назад +3

    Hello! Ty for this great tutorial! I have a problem. When I generate the types, it doesn't come with the sections in it. It throws an Error on the export saying that the type is missing the fields and contentTypeId. Can you help me pls? this is what it generates:
    import type { Asset, Entry, EntryFields } from "contentful";
    export interface TypeAuthorFields {
    name: EntryFields.Symbol;
    description: EntryFields.Text;
    avatar: Asset;
    }
    export type TypeAuthor = Entry;

    • @gergoradeczki
      @gergoradeczki Год назад +1

      `cf-content-types-generator` did not receive an update in a long time, but the `contentful` package did. So, they are out of sync right now.
      Downgrade to like _10.0.0-beta-v10.8_ the `contentful` package and you should be good to go.