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 Parameter | Description |
|---|---|
TInput | First unit-tagged type |
TOutput | Second unit-tagged type |
Properties
| Property | Type | Defined in |
|---|---|---|
from | RelaxedConverter<TOutput, TInput> | packages/core/src/converters.ts:196 |
to | RelaxedConverter<TInput, TOutput> | packages/core/src/converters.ts:195 |