Skip to content

⬅️ Back to Table of Contents

📄 nullThrows.ts

📊 Analysis Summary

Metric Count
🔧 Functions 5
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

📂 packages/utils/src/eslint-utils/nullThrows.ts

Variables & Constants

Name Type Kind Value Exported
NullThrowsReasons { readonly MissingParent: "Expected node to have a parent."; readonly MissingToken: (token: string, thing: string) => string; } const `{
MissingParent: 'Expected node to have a parent.',
MissingToken: (token: string, thing: string) =>
Expected to find a ${token} for the ${thing}.,
} as const`

Functions

MissingToken(token: string, thing: string): string

Code
(token: string, thing: string) =>
    `Expected to find a ${token} for the ${thing}.`
  • Parameters:
  • token: string
  • thing: string
  • Return Type: string

MissingToken(token: string, thing: string): string

Code
(token: string, thing: string) =>
    `Expected to find a ${token} for the ${thing}.`
  • Parameters:
  • token: string
  • thing: string
  • Return Type: string

MissingToken(token: string, thing: string): string

Code
(token: string, thing: string) =>
    `Expected to find a ${token} for the ${thing}.`
  • Parameters:
  • token: string
  • thing: string
  • Return Type: string

MissingToken(token: string, thing: string): string

Code
(token: string, thing: string) =>
    `Expected to find a ${token} for the ${thing}.`
  • Parameters:
  • token: string
  • thing: string
  • Return Type: string

nullThrows(value: T, message: string): NonNullable<T>

Code
export function nullThrows<T>(value: T, message: string): NonNullable<T> {
  if (value == null) {
    throw new Error(`Non-null Assertion Failed: ${message}`);
  }

  return value;
}
  • JSDoc:

    /**
     * Assert that a value must not be null or undefined.
     * This is a nice explicit alternative to the non-null assertion operator.
     */
    

  • Parameters:

  • value: T
  • message: string
  • Return Type: NonNullable<T>