ts-data-forge
    Preparing search index...

    Function isSymbol

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

      Type Narrowing Behavior:

      • Narrows unknown to symbol when true
      • Identifies values created with Symbol() constructor

      Parameters

      • u: unknown

        The value to check

      Returns u is symbol

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

      const id = Symbol('id');
      const shared = Symbol.for('shared');
      const tokens: unknown[] = [id, 'shared', shared];

      const symbols = tokens.filter(isSymbol);

      assert.deepStrictEqual(symbols, [id, shared]);