Skip to content

TypeScript Types

Ornata also exposes a public TypeScript type surface in addition to its runtime exports.

Use these when you want to derive types from an existing component constructor:

TypeDescription
InferComponentInstanceDerives the mounted public instance type from a component constructor.
InferComponentStateDerives the mounted public state type from a component constructor.

Use these when defining, mounting, or sharing component contracts:

TypeDescription
ComponentOptionsThe full options object accepted by defineComponent() when using explicit types.
ComponentConstructorThe constructor returned by defineComponent(), including mounting and lookup helpers.
ComponentInstanceThe public mounted instance type exposed to outside code.

Use these types when defining or shaping a component contract:

TypeDescription
RootOptionsRoot validation options used to constrain or verify the mounted root.
StateOptionsConfiguration for a single state property, including defaults, parsing, and safeguards.
ElementOptionsConfiguration for a single element entry, including queries, creation, resolution, and count checks.
MethodDefinitionThe callback type used for component methods with this bound to the internal instance.
RenderOptionsThe object returned by render callbacks to describe DOM updates.

Use these when you want explicit types for callback signatures and their context objects:

TypeDescription
WatchContextThe context object passed to watch callbacks.
ComputedContextThe context object passed to computed callbacks.
RenderContextThe context object passed to render callbacks.
WatchCallbackThe callback signature for watch entries with internal-instance this.
ComputedCallbackThe callback signature for computed entries with internal-instance this.
RenderCallbackThe callback signature for render entries that return RenderOptions.

Use these when typing public state subscriptions:

TypeDescription
StateListenerEventThe event payload emitted when a public state property changes.
StateListenerThe callback signature for public state subscriptions.
StateListenerCleanupThe cleanup function returned by addStateListener().

For a more guide-oriented explanation of explicit typing patterns, read TypeScript.