gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example in Tuples.GroupBy is incorrect

cstria0106 opened this issue · comments

Document says

interface IsNumber extends Fn {
  return: this["arg0"] extends number ? true : false;
}

type T0 = Call<Tuples.GroupBy<IsNumber>, [1, "str", 2]>;
//   ^? { true: [1, 2], false: ["str"] }
type T2 = Call<Tuples.GroupBy<Strings.StartsWith<"a">>, ["alice", "bob", "carl"]>;
//   ^? { true: ["alice"], false: ["bob", "carl"] }

But it's actually

interface IsNumber extends Fn {
  return: this['arg0'] extends number ? true : false;
}

type T0 = Call<Tuples.GroupBy<IsNumber>, [1, 'str', 2]>;
// never
type T2 = Call<Tuples.GroupBy<Strings.StartsWith<'a'>>, ['alice', 'bob', 'carl']>;
// never

Because boolean can not be the property name