Skip to main content

Typechecking

Stories and Storybooks are plain ModuleScripts, so by default a mistake in their shape (a missing story function or a misspelled field) only surfaces when Flipbook loads them. Storyteller, the library behind Flipbook, exports types you can annotate with to catch those mistakes as you write instead.

Add Storyteller to your project (via Wally, or the released model from the Storyteller repo), then annotate your modules.

Annotate a Storybook with Storyteller.Storybook:

React.storybook.luau
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")
local Storyteller = require("@pkg/Storyteller")

local storybook: Storyteller.Storybook = {
name = "React (Storyteller)",
storyRoots = {
script.Parent,
},
packages = {
React = React,
ReactRoblox = ReactRoblox,
},
}

return storybook

And a Story with Storyteller.Story<T>, where T is the type your story function returns:

ReactButton.story.luau
local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local ReactButton = require("./ReactButton")

local story: Storyteller.Story<unknown> = {
story = function()
return React.createElement(ReactButton, {
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}

return story

With these annotations in place, Luau analysis (for example luau-lsp in your editor) flags a malformed Storybook or Story before you ever open it in Flipbook: a missing story, a mistyped storyRoots, or a control whose shape doesn't match.

Storyteller also exports Storyteller.StoryProps for the object passed to your story function, and the control types (Storyteller.StoryControlsSchema and the individual *Control types) for annotating controls.