ts-data-forge
    Preparing search index...

    Function isNotUndefined

    • Type guard that checks if a value is not undefined.

      Type Narrowing Behavior:

      • Excludes undefined from the input type when true
      • Preserves all other types in the union
      • Commonly used to filter out undefined values

      Type Parameters

      • T

        The type of the input value

      Parameters

      • u: T

        The value to check

      Returns u is RelaxedExclude<T, undefined>

      true if u is not undefined, false otherwise. When true, TypeScript excludes undefined from the type.

      const values: (number | undefined)[] = [1, undefined, 2];

      const definedValues = values.filter(isNotUndefined);

      assert.deepStrictEqual(definedValues, [1, 2]);