ts-data-forge
    Preparing search index...

    Function isBoolean

    • Type guard that checks if a value is a boolean.

      Type Narrowing Behavior:

      • Narrows unknown to boolean when true
      • Preserves literal boolean types (true | false)

      Parameters

      • u: unknown

        The value to check

      Returns u is boolean

      true if u is a boolean, false otherwise. When true, TypeScript narrows the type to boolean.

      const flags: unknown[] = [true, 'no', false];

      const booleans = flags.filter(isBoolean);

      assert.deepStrictEqual(booleans, [true, false]);