Skip to content

unacy / RelaxedBidirectionalConverter

Type Alias: RelaxedBidirectionalConverter<TInput, TOutput>

ts
type RelaxedBidirectionalConverter<TInput, TOutput> = {
  from: RelaxedConverter<TOutput, TInput>;
  to: RelaxedConverter<TInput, TOutput>;
};

Defined in: packages/core/src/converters.ts:194

A bidirectional converter with relaxed (unwrapped) output types. Input remains branded for full autocompletion and type safety; return values are plain base types without branding.

Example

typescript
const celsiusFahrenheit: RelaxedBidirectionalConverter<Celsius, Fahrenheit> = {
  to: (c) => (c * 9/5) + 32,   // returns number, not Fahrenheit
  from: (f) => (f - 32) * 5/9  // returns number, not Celsius
};

Use When

You want the ergonomics of RelaxedConverter (no return-value cast) for both directions in a single object, typically for registry.register().

See

  • BidirectionalConverter
  • RelaxedConverter

Type Parameters

Type ParameterDescription
TInputFirst unit-tagged type
TOutputSecond unit-tagged type

Properties

PropertyTypeDefined in
fromRelaxedConverter<TOutput, TInput>packages/core/src/converters.ts:196
toRelaxedConverter<TInput, TOutput>packages/core/src/converters.ts:195

Released under the MIT License.