dohomi / storyblok-generate-ts

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

Custom Plugin fields are not included in the generated TypeScript schema #60

Closed mixmav closed 10 months ago

mixmav commented 10 months ago

When I add a custom plugin field of, for example, a native color picker, the Blok doesn't include that field in its generated schema at all, even though the JSON returned contains the information.

Is this by design? If not, any suggestions on a workaround would be appreciated. Thanks 🤝

image image

dohomi commented 10 months ago

everything which is not a Storyblok component (plugins) can't know the definition, so if you do have a custom plugin you need to extend the type declaration as its not possible to know what the plugin is doing under the hood.

mixmav commented 10 months ago

@dohomi Thanks for the quick response! How would I go about extending the type declaration?

Should I create a new custom type, for example ColorPickerStoryblok, and manually add it to the CountdownStoryblok type definition after importing it? Any way to semi-automate this?

dohomi commented 10 months ago

you can use https://github.com/dohomi/storyblok-generate-ts?tab=readme-ov-file#example-custom-parser for your custom plugin thats the easiest to integrate you can add it via the https://github.com/dohomi/storyblok-generate-ts?tab=readme-ov-file#properties-of-cli