api / type

GenericTrap

Generic trap with basic operations available for all types.

Source: src/api/traps/types.ts

Generic trap with basic operations available for all types.

Signature

export type GenericTrap<T> = {
  /** Converts the value to a string signal. */
  get string(): DerivedSignal<T extends null | undefined ? undefined : string>;
  /** Returns the value if truthy, otherwise the fallback value. */
  or: <OV>(orValue: MaybeSignalValue<OV>) => DerivedSignal<NonNullable<T> | OV>;
};

Type Parameters

  • The type of value