edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
509 stars 64 forks source link

e.group inside e.select gives Typescript error #545

Open themajashurka opened 1 year ago

themajashurka commented 1 year ago

Code The code causing the error.

const group = e.group(e.Foo, (x) => ({
  by: { bar: x.bar },
}))

const select = e.select(group, x => ({
  count:e.count(x.elements)
}))

Schema

Your application schema.

module default {
    type Foo {
        required property bar -> str;
    }
}

Error or desired behavior

I've seen a couple of people experiencing the same on Discord and here #421, while wrapping e.group with a e.select. Autocompletion kind of works inside the expressions, but TS underlines const select = ... with an error.

Outer e.select could be pretty useful for group aggregations, and reshaping the free object output of e.group.

I've fought that some part of my schema produces the error, but this issue seems to be reproducible even with this minimal one.

Excessive stack depth comparing types '$expr_Operator<ScalarType<"std::str", string, string>, multiplyCardinalities<(S extends TypeSet<BaseType, Cardinality> ? S["__cardinality__"] : Cardinality.One) extends Cardinality.Empty ? Cardinality.Empty : Cardinality.Many, E extends TypeSet<...> ? C : Cardinality.One>>' and '$expr_Operator<ScalarType<"std::str", string, string>, multiplyCardinalities<(S extends TypeSet<BaseType, Cardinality> ? S["__cardinality__"] : Cardinality.One) extends Cardinality.Empty ? Cardinality.Empty : Cardinality.Many, E extends TypeSet<...> ? C : Cardinality.One>>'

Versions (please complete the following information):

themajashurka commented 1 year ago

It seems that TS 5.1.0-dev20230306 solves the issue, but might break tomorrow :) Im not aware yet what change plays a role here.