storyblok-generate-ts
storyblok-generate-ts copied to clipboard
On custom SB type generate - includes import of StoryBloKStory?
I have this:
const storyblokToTypescript = require("storyblok-generate-ts").default
storyblokToTypescript({
componentsJson: require("./components.xxxxx.json"),
path: __dirname + "/sb-types.ts",
titlePrefix: "nc",
compilerOptions: {
additionalProperties: false,
unknownAny: false,
},
})
It generates:
import { StoryblokStory } from "storyblok-generate-ts"
export interface NcfeatureStoryblok {
name?: string
_uid: string
component: "feature"
}
export interface NcgridStoryblok {
columns?: (
| NcfeatureStoryblok
| NcgridStoryblok
| NcpageStoryblok
| NcteaserStoryblok
)[]
_uid: string
component: "grid"
}
export interface NcpageStoryblok {
body?: (
| NcfeatureStoryblok
| NcgridStoryblok
| NcpageStoryblok
| NcteaserStoryblok
)[]
_uid: string
component: "page"
uuid?: string
}
export interface NcteaserStoryblok {
headline?: string
_uid: string
component: "teaser"
}
How to exclude the import?
as soon you'd use single/multiple option fields or a bunch of other Storyblok features this type gets mandatory. There could be an option for very simple schema to leave it out, but I am currently busy with other things. Feel free to open a PR if you want to leave the type out