Tea’s JavaScript API surface —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
State, Macro, Dialog, Save, Config, and more — can be used with TypeScript type checking in Tweego-based projects. Type declarations are available through the Definitely Typed package @types/twine-sugarcube, which provides type information for the full SugarCube 2 API that Tea is built on.
Installing Type Declarations
Install the package as a development dependency via npm:State, Macro, Config, Story, Engine, Save, Dialog, UI, etc.) in any .ts file in your project.
Project Setup
What the Type Declarations Cover
The@types/twine-sugarcube package provides types for:
- The
StateAPI (variables, temporary variables, history, PRNG) - The
MacroAPI (Macro.add,MacroContext) - The
ConfigAPI (all configuration properties) - The
SaveAPI (browser slots, autosaves, disk saves, base64) - The
Dialog,UI,Engine,Story, andPassageAPIs - Built-in functions (
clone,memorize,recall,forget,visited,passage,tags, etc.) - jQuery extensions added by SugarCube
Because Tea is a fork of SugarCube 2, the
@types/twine-sugarcube declarations closely match Tea’s API. Any Tea-specific additions or changes may not yet be reflected in the Definitely Typed package.Example: Typed Macro Registration
Example: Typed Story Variable Access
Story variables in SugarCube/Tea are accessed at runtime viaState.variables, which is typed as a plain object. You can augment the type for better safety: