tguard-js
    Preparing search index...

    Function isNonNullish

    • Checks if a value is neither null nor undefined (i.e., "non-nullish"). This is a type guard that narrows the type away from null and undefined.

      Type Parameters

      • T

        The type of the input value.

      Parameters

      • x: T

        The value to check.

      Returns x is NonNullable<T>

      true if the value is not null and not undefined, false otherwise.

      let myValue: string | null = "hello";
      if (isNonNullish(myValue)) {
      // myValue is now typed as string
      }

      1.0