Aller au contenu principal

invariant

Callable

  • invariant(condition: false, message?: null | string): never
  • invariant(condition: boolean, message?: null | string): asserts condition

  • Assert that condition is truthy, else throws Error { name: 'InvariantError', message }

    In production environment, message parameter could be stripped from source in order to reduce file size

    @example
    invariant(true, 'this should be true');// pass
    invariant(false, 'this should be true');// throw new Error('this should be true')