Skip to Content
Documentation

songstress/ui/jsx-runtime

What a .tsx file's JSX compiles to, with jsxImportSource songstress/ui, and the JSX types of client code.

A .tsx file whose jsxImportSource is songstress/ui (the starter's tsconfig.json says so, and songstress build assumes it with no tsconfig.json at all) compiles each element to jsx from this entry. Its JSX namespace is the types of client code: a tag is one of songstress/ui's components or one of your own, never a lower-case name, and a handler may be a function. You never import this entry yourself; the compiler and the bundler do.

songstress/ui/jsx-dev-runtime is what a development build (Vitest, an editor's preview) imports in its place, with the same elements.

Fragment · JSX · jsx · jsxs

Fragment

Groups children without a node of its own.

export declare const Fragment: (props: {
    children?: UiNode;
}) => UiElement;

Refers to UiNode, UiElement.

JSX

The JSX of client code: a tag is a component, never a lower-case name; a handler may be a function.

export declare namespace JSX {
    type Element = UiElement;
    type ElementType = (props: never) => UiNode | Screen | PanelContent | StatusContent;
    interface ElementChildrenAttribute {
        children: unknown;
    }
    interface IntrinsicAttributes {
        key?: string | number;
    }
    interface IntrinsicElements {
    }
}

Refers to UiElement, UiNode, Screen, PanelContent, StatusContent.

jsx

The JSX factory: what a .tsx file compiles each element to, with jsxImportSource songstress/ui (or songstress/ui/server for server code). A tag is a component of songstress/ui or one of the author's own, never a lower-case name.

export declare function jsx(type: unknown, props: Record<string, unknown> | null, key?: string | number): UiElement;
ParameterTypeDescription
typeunknownThe component.
propsRecord<string, unknown> | nullIts props, children among them.
key?string | numberIts JSX key: the node's key on the wire.

Returns UiElement.

Example
import { jsx } from 'songstress/ui/jsx-runtime'
import { Text } from 'songstress/ui'

// What `<Text style="title">Played lately</Text>` compiles to.
const title = jsx(Text, { style: 'title', children: 'Played lately' })

Refers to UiElement.

jsxs

The JSX factory of an element with several children, which a compiler tells apart from jsx: here they are one function.

export declare const jsxs: typeof jsx;

Refers to jsx.

jsxDEV

It also exports, as the modules that declare them document them: Fragment, JSX.

jsxDEV

The JSX factory of a development build: jsx, with what such a build adds about where the element was written left aside.

export declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): UiElement;
ParameterTypeDescription
typeunknownThe component.
propsRecord<string, unknown> | nullIts props, children among them.
key?string | numberIts JSX key.

Returns UiElement.

Example
import { jsxDEV } from 'songstress/ui/jsx-dev-runtime'
import { Text } from 'songstress/ui'

const title = jsxDEV(Text, { children: 'Played lately' })

Refers to UiElement.