Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

[v4] Generated StoryblokRichtext type not compatible with renderRichText from @storyblok/js #247

@mledl

Description

@mledl

Current behavior:
We are using @storyblok/js renderRichtext function to render the richtext fetched from Storyblok. After migrating to v4 of the storyblok-cli we noticed that there is a discrepancy in the types generated by the cli and the typ expected by renderRichtext. This becomes a static issue when exactOptionalPropertyTypes: true set in tsconfig.json.

Signature of renderRichtext:

export declare function renderRichText<T = string>(data: StoryblokRichTextNode<T>, options?: StoryblokRichTextOptions<T>): T | undefined;

where

interface StoryblokRichTextNode<T = string> {
  type: StoryblokRichTextNodeTypes;
  content: StoryblokRichTextNode<T>[];
  children?: T;
  attrs?: Record<string, any>;
  text?: string;
}

The generated StoryblokRichtext type:

interface StoryblokRichtext {
	type: string
	content?: StoryblokRichtext[]
	marks?: StoryblokRichtext[]
	attrs?: Record<string, any>
	text?: string
}

Expected behavior:
The type match and renderRichtext can be used as expected.

Steps to reproduce:

  1. Generate types using:
storyblok types generate --space <spaceId> --strict
  1. Try to call @storyblok/js renderRichtext function with a some attribute of type StoryblokRichtext generated via the CLI tool.
  2. Your tsconfig.json must specify exactOptionalPropertyTypes: true

Other information:
Looking forward to getting this resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions