Repository navigation
[storyblok/cli] Feature Request: Proper TypeScript types for blocks fields using Denylist configuration #482
thomas-wtfoxtrot
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When a blocks field in a Storyblok component schema is configured using the Denylist mode (exclude specific blocks rather than allowlisting them), the CLI's
generate-componentscommand generatesany[]as the TypeScript type for that field.In contrast, a field using the traditional Whitelist/Allowlist mode generates a precise union type listing every permitted component interface.
CLI version: 4.16.0Example of current output for a denylist-configured field:
Example for an equivalent allowlist-configured field:
This means adopting the Denylist feature — which is otherwise ergonomic when you want to exclude only a small number of blocks from a large set — forces a regression in type safety. Consumers lose autocomplete, exhaustiveness checking in renderers, and compile-time guarantees about which blocks can appear.
Expected Behavior
The CLI should generate the semantic equivalent of the denylist configuration: a union of all registered nestable components minus the denied ones.
Conceptually:
Or alternatively, the CLI could expand this to an explicit union by computing the set difference at generation time:
Why this matters
any[]removes all compile-time safety.Suggested implementation note
The component schema returned by the Management API includes both the denylist entries and the full list of nestable components in the space. At generation time, the CLI already has all the information needed to compute the set difference and emit either an
Exclude<>-helper or an expanded union, no additional API calls required.Workaround (current)
Avoid the Denylist and maintain a full allowlist manually — which defeats the purpose of the feature.
Affected CLI command: storyblok generate-components
CLI version: 4.16.0
Severity: Medium — affects all TypeScript users who adopt the Denylist feature
PS: While working on it, you could also rename the
whitelisttoallowlistin contrast to the existingdenylistfor a more consistent and up-to-date API.All reactions