📦
unwrapit
  • 👋Welcome to unwrapit
  • Intro
    • 💡Why use it?
    • ✨Getting Started
  • APIs
    • 🔨wrap
    • 🔨unwrap
    • 🔨unwrapOr
    • 🔨unwrapOrElse
    • 🔨expect
    • 🔨mapErr
    • 🔨defineWrapConfig
    • 🔨ok
    • 🔨err
  • Type
    • 🔧Result
    • 🔧WrapConfig
    • 🔧WrapOption
    • 🔧Panic
  • Recipe
    • 🎨Export Wrapped Functions
    • 🎨Return Result Without `wrap` it
Powered by GitBook
On this page
  1. Type

Result

type Result<T, E = unknown> = Ok<T> | Err<E, T>

Result accepts 2 type parameters, T is the ok value type, E is the error value type.

Ok and Err are 2 internal types, you shouldn't use them directly.

Example

You can create a Result type by calling 2 functions ok and err.

const r1 = ok(1)
//    ^? const r1: Result<number, never>

const r2 = err(1)
//    ^? const r2: Result<unknown, number>
PreviouserrNextWrapConfig

Last updated 1 year ago

🔧