Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On custom SB type generate - includes import of StoryBloKStory? #66

Open
Galanthus opened this issue Mar 6, 2024 · 1 comment
Open

Comments

@Galanthus
Copy link

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?

@dohomi
Copy link
Owner

dohomi commented Mar 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants