dohomi / storyblok-generate-ts

Generates TypeScript interface types based on Storyblok component file
MIT License
102 stars 33 forks source link

Unexpected & inconsistent type generation when source of Multi-Options field is set to Languages #77

Open suateneskoc opened 2 weeks ago

suateneskoc commented 2 weeks ago

Type of a field that is used in many of our blocks in our schema has started to be generated differently.

Many of our blocks include a field we call _hidden_forlanguages. Field type of these fields is Multi-Options and Source of options is set to Languages.

The type generated for such fields that were created in the past is generated as such

hidden_for_languages?: (
    | 'nl'
    | 'en'
    | 'fi'
    | 'fr'
    | 'de'
    | 'it'
    | 'pt'
    | 'es'
  )[];

However, the following type is being generated for the most recent instances of _hidden_forlanguages with exactly same settings as before

  hidden_for_languages?: string[];

The new type is not only worse, but also inconsistent with _hidden_forlanguages fields created in the past. Could you please support? 🙏🏻

dohomi commented 2 weeks ago

I am not aware of any change in the API, could you point me from which version onwards this issue occurs? Is this a change on the Storyblok side?

suateneskoc commented 1 week ago

I suspect it to be a change on Storyblok side. Can't tell approximately when, but Languages was added as a Source option not too long ago. Although we have been on the latest version of storyblok-generate-ts (2.1.0) for the last 6 months, only noticed this behaviour recently.

dohomi commented 1 week ago

I don't use that feature you describing at all in my setup, so I really don't know where to look at. You can always overwrite the created interfaces to be more precise, otherwise it would be great to chat with some devs from Storyblok what might be the reason for this