@glideapps/ts-necessities
    Preparing search index...

    Function isArray

    • Returns whether x is an array.

      We have this because Array.isArray(x) returns x is any[], which means that this code compiles without error, for example:

      function thisShouldNotCompile(x: string | readonly string[]) {
      if (Array.isArray(x)) {
      const s = x[0];
      s.thisIsAnAny("but it's actually a string");
      }
      }

      Type Parameters

      • T
      • U

      Parameters

      • x: U | readonly T[]

      Returns x is readonly T[]

    • Returns whether x is an array.

      We have this because Array.isArray(x) returns x is any[], which means that this code compiles without error, for example:

      function thisShouldNotCompile(x: string | readonly string[]) {
      if (Array.isArray(x)) {
      const s = x[0];
      s.thisIsAnAny("but it's actually a string");
      }
      }

      Type Parameters

      • T
      • U

      Parameters

      • x: U | T[]

      Returns x is T[]