edgedb / edgedb-js

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

Queries that return an `AtLeastOne` scalar are inferred as `T[]` instead of `[T, ...T[]]` #1072

Closed scotttrinh closed 2 months ago

scotttrinh commented 3 months ago

Sample query:

select { "a", "b", "c" };

Generates the following TypeScript function:

export type SetOfStrsReturns = [string, ...string[]];

export function setOfStrs(client: Executor): Promise<SetOfStrsReturns> {
  return client.query(`\
select { "a", "b", "c" }`);

}

The query function gets its generic inferred as string, which makes the return value from query become string[] given the definition of query. We do not currently have a query method like queryRequired that correctly returns [T, ...T[]] instead of T[].

scotttrinh commented 2 months ago

Closed in #1074, released in @edgedb/generate@0.5.5