smolter
Types

DataOf

Extracts the awaited successful result of a function.

Compatibility

ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/react @kasperrt/smolter/preact

Signature

type DataOf<F> = F extends AnyDataFunction
  ? Exclude<Awaited<ReturnType<F>>, Error>
  : undefined;

Usage

Extracts the awaited successful result of a function. Error results are excluded. This is the basis for the data-hook generic types; it does not validate JSON at runtime.

type Task = DataOf<typeof loader>;
View implementation ↗