News for hackers. Stuff that matters.
Re:TIL: `satisfies` is my favorite TypeScript keyword by kaoD on Saturday November 22, 2025 @06:12PM (#46019187)
For those unfamiliar with TS, the above is just...

    function flat([head, ...tail]) {
      return Array.isArray(head)
        ? [...flat(head), ...flat(tail)]
        : [head, ...flat(tail)]
    }
...in TS syntax.
Re:TIL: `satisfies` is my favorite TypeScript keyword by tomsmeding on Saturday November 22, 2025 @06:37PM (#46019350)
Well, it is the type of that, in TS syntax. Few are the statically-typed languages that can even express that type.
Re:TIL: `satisfies` is my favorite TypeScript keyword by not_kurt_godel on Saturday November 22, 2025 @11:02PM (#46020651)
Java: List<Object>

Python: list[Any]

...what am I missing?

Re:TIL: `satisfies` is my favorite TypeScript keyword by sli on Sunday November 23, 2025 @02:03AM (#46021424)
You're missing the input type, essentially. Those are just array types. The TypeScript type signature more of a function type, it expresses flattening a n-dimensional array (input type) into a flat array (output type).
Re:TIL: `satisfies` is my favorite TypeScript keyword by rjh29 on Sunday November 23, 2025 @02:49AM (#46021613)
You're missing the specialisation of Object/Any. For example Array.flat called with [int, [bool, string]] returns a type [int, bool, string]. Admittedly this is somewhat niche, but most other languages can't express this - the type information gets erased.