File size: 367 Bytes
d9494a5
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import { isDefined } from '@/utils';

// https://github.com/microsoft/TypeScript/issues/34523
// oxlint-disable-next-line prefer-arrow/prefer-arrow-functions
export function assertIsDefinedOrThrow<T>(
  value: T | undefined | null,
  exceptionToThrow: Error = new Error('Value not defined'),
): asserts value is T {
  if (!isDefined(value)) throw exceptionToThrow;
}