ts-data-forge
    Preparing search index...

    Function isString

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

      Type Narrowing Behavior:

      • Narrows unknown to string when true
      • Preserves literal string types when possible
      • Includes empty strings

      Parameters

      • u: unknown

        The value to check

      Returns u is string

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

      const values: unknown[] = ['Ada', 42, 'Lovelace'];

      const strings = values.filter(isString);

      assert.deepStrictEqual(strings, ['Ada', 'Lovelace']);