ts-data-forge
    Preparing search index...

    Function isNotNull

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

      Type Narrowing Behavior:

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

      Type Parameters

      • T

        The type of the input value (which could be null)

      Parameters

      • u: T | null

        The value to check

      Returns u is T

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

      const values: (number | null)[] = [null, 5];

      const nonNullValues = values.filter(isNotNull);

      assert.deepStrictEqual(nonNullValues, [5]);