Skip to content

TypedValue

TypedValue = { amount: number; currency: string; type: "currency"; } | { precision?: number; type: "number"; unit?: string; value: number; } | { precision?: number; type: "percent"; value: number; } | { seconds: number; type: "duration"; } | { type: "date"; value: WireDate; } | { timeZone?: string; type: "clock"; } | { type: "text"; value: string; } | number | string

A value handed over raw so each surface can format it for the viewer’s own locale. Never pre-format a number into a string yourself (no "$1,247"): use one of the typed cases, or the currency/number/percent/duration/ date helpers that build them. text is for values that are genuinely text (a status word, a username), not a workaround for formatting.

A bare JSON number is shorthand for { type: "number", value }, and a bare JSON string is shorthand for { type: "text", value }. Both decode fine in the app, but prefer the explicit typed forms so the renderer knows what it’s showing.

{ amount: number; currency: string; type: "currency"; }


{ precision?: number; type: "number"; unit?: string; value: number; }


{ precision?: number; type: "percent"; value: number; }


{ seconds: number; type: "duration"; }


{ type: "date"; value: WireDate; }


{ timeZone?: string; type: "clock"; }

The current time of day in an IANA zone (the viewer’s own when omitted); the renderer keeps it current.


{ type: "text"; value: string; }


number


string