unacy / BaseMetadata
Type Alias: BaseMetadata
type BaseMetadata = {
name: string;
};Defined in: packages/core/src/types.ts:421
Base metadata type that all unit metadata must extend. Requires a name property and allows arbitrary additional properties.
Remarks
name is the registry key — it must be a string literal (as const) so that the type-level accessor map (UnitMap) can index by it. At runtime it is also the adjacency-map key used for BFS path finding, so names must be unique within a registry.
Example
const CelsiusMeta = {
name: 'Celsius' as const, // must be a literal
symbol: '°C',
description: 'Temperature in Celsius'
} satisfies BaseMetadata;Use When
Defining metadata for a unit that only needs a name and optional display fields (symbol, abbreviation, description). For units where the base type matters in conversions, use TypedMetadata<T>.
Pitfalls
NEVER use a non-literal string for name (e.g., name: string instead of name: 'Celsius' as const) — the registry key becomes string and the compile-time accessor registry.Celsius.to.Fahrenheit stops resolving.
NEVER reuse the same name value across two different unit objects in the same registry — the second registration silently overwrites the first.
Config
Additional properties (e.g., symbol, abbreviation, description) are accessible as registry.<UnitName>.<property> after registration.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
name | string | Unique identifier for the unit (replaces tag) | packages/core/src/types.ts:423 |