• Konlanx@feddit.de
    link
    fedilink
    arrow-up
    24
    ·
    edit-2
    1 year ago

    This is likely referring to TypeScript.

    TypeScript has all of these patterns, they are used very frequently and they are necessary because TypeScript tends to be interesting from time to time since its types only exist at compile time, because it compiles to JavaScript, which is a language without types.

    TypeScript also allows any as a keyword, which says “I don’t know which type this is and I don’t care”, which still produces valid JavaScript. To get back to typed variables it is necessary to use typeof (or similar constructs like a type guard).

    https://www.typescriptlang.org/docs/handbook/2/typeof-types.html

    • jana@leminal.space
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 year ago

      But generic type syntax is a feature exclusive to Typescript while typeof is a JavaScript thing. You’d never get Pie[Pie[T]] as a result from a typeof check. (Please excuse the square brackets; seems like the markdown parser here isn’t quite right and it keeps messing up the angle brackets)

      Also, it’s typeof foo not typeof(foo) in js

    • m_r_butts@kbin.social
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Given the callout as a mixin, you’re probably right. Other languages have them, but I’ve only heard something described in practice as a mixin working in Angular and Typescript. (Neither of which are my forte, so if I’m wrong, I’m wrong.)